From 00540a38be97858e71163f53dddf8dee53185b1d Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 10 Dec 2005 20:37:09 +0100 Subject: unobstrusive JS for TOC, better onload handling This path adds more unobstrusive JavaScript for the TOC handling. It also loads JavaScript initialiezers as soon as the DOM is parsed for Mozilla-based Browsers as described at http://dean.edwards.name/weblog/2005/09/busted/ - a IE solution was not chosen yet. darcs-hash:20051210193709-7ad00-771461e56d9661caf9ca733a6d617f009e24d0b7.gz --- lib/exe/js.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/exe') diff --git a/lib/exe/js.php b/lib/exe/js.php index ca1d83948..b776f957b 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -77,6 +77,7 @@ function js_out(){ // init stuff js_runonstart("ajax_qsearch.init('qsearch_in','qsearch_out')"); js_runonstart("addEvent(document,'click',closePopups)"); + js_runonstart('addTocToggle()'); if($edit){ // size controls @@ -114,6 +115,13 @@ function js_out(){ // load user script @readfile(DOKU_CONF.'userscript.js'); + + // initialize init pseudo event + echo 'if (document.addEventListener) {'; + echo ' document.addEventListener("DOMContentLoaded", window.fireoninit, null);'; + echo '}'; + echo 'addEvent(window,"load",window.fireoninit);'; + // end output buffering and get contents $js = ob_get_contents(); ob_end_clean(); @@ -184,7 +192,7 @@ function js_escape($string){ * @author Andreas Gohr */ function js_runonstart($func){ - print "addEvent(window,'load',function(){ $func; });"; + echo "addInitEvent(function(){ $func; });"; } /** -- cgit v1.2.3