From 5cafff964bdbfadfa66e4752eb6b392d2fce9087 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 16 Jun 2006 12:45:39 +0200 Subject: better onload handling This patch improves the way the window.oninit JavaScript function is called. This function is used to initialiaze all JavaScript funcions attached to the DOM so it needs to be executed **after** the full DOM was parsed by the browser. Unfortunately currently only Mozilla supports a DOMContentLoaded event. In all other browsers we had to wait for the window.onload event which will only be called after **all** content (including images) was loaded - this caused a visible delay on all JavaScript generated content (like the toolbar) in non-Mozilla browsers. Dean Edwards now presented a solution [1] which will work for all the bigger Browsers and is used in this patch. The following browsers now should fire the init event right after parsing the DOM: All Mozilla based browsers Internet Explorer Safari Opera > darcs-hash:20060616104539-7ad00-db70d31fcb21cb812cf4982fe80a7d649e2daa1c.gz --- lib/exe/js.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/exe/js.php') diff --git a/lib/exe/js.php b/lib/exe/js.php index de996a117..75b9b1f1c 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -143,11 +143,11 @@ function js_out(){ js_runonstart('scrollToMarker()'); js_runonstart('focusMarker()'); - // initialize init pseudo event +/* // initialize init pseudo event echo 'if (document.addEventListener) {'.NL; echo ' document.addEventListener("DOMContentLoaded", window.fireoninit, null);'.NL; echo '}'.NL; - echo 'addEvent(window,"load",window.fireoninit);'.NL; + echo 'addEvent(window,"load",window.fireoninit);'.NL;*/ // end output buffering and get contents $js = ob_get_contents(); @@ -245,8 +245,8 @@ function js_compress($s){ while($i < $len){ $ch = $s{$i}; - // multiline comments - if($ch == '/' && $s{$i+1} == '*'){ + // multiline comments (keeping IE conditionals) + if($ch == '/' && $s{$i+1} == '*' && $s{$i+2} != '@'){ $endC = strpos($s,'*/',$i+2); if($endC === false) trigger_error('Found invalid /*..*/ comment', E_USER_ERROR); $i = $endC + 2; -- cgit v1.2.3