[Rt-commit] r14783 - in rt/3.8/trunk: . share/html/NoAuth/js

falcone at bestpractical.com falcone at bestpractical.com
Tue Aug 5 11:45:02 EDT 2008


Author: falcone
Date: Tue Aug  5 11:45:01 2008
New Revision: 14783

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/share/html/Elements/HeaderJavascript
   rt/3.8/trunk/share/html/NoAuth/js/util.js

Log:
 r37725 at ketch:  falcone | 2008-08-05 11:44:18 -0400
 * don't clobber window.onload, use prototype to handle cross
   browser peculiarities in onload behaviour
 
 RT-Ticket: 10751
 RT-Action: Correspond
 RT-Status: resolved


Modified: rt/3.8/trunk/share/html/Elements/HeaderJavascript
==============================================================================
--- rt/3.8/trunk/share/html/Elements/HeaderJavascript	(original)
+++ rt/3.8/trunk/share/html/Elements/HeaderJavascript	Tue Aug  5 11:45:01 2008
@@ -58,9 +58,9 @@
 <script type="text/javascript" src="<%RT->Config->Get('WebPath')%>/NoAuth/RichText/fckeditor.js"></script>
 % }
 <script type="text/javascript"><!--
-    onLoadHook("loadTitleBoxStates()");
+    doOnLoad(loadTitleBoxStates);
 % if ( $focus ) {
-    onLoadHook("focusElementById('<% $focus %>')");
+    doOnLoad(function () { focusElementById('<% $focus %>') });
 % }
 
 % if ( RT->Config->Get('MessageBoxRichText',  $session{'CurrentUser'})) {
@@ -110,9 +110,9 @@
             }
         }
     }
-    onLoadHook("ReplaceAllTextareas()");
+    doOnLoad(ReplaceAllTextareas);
 % }
 % if ( $onload ) {
-    onLoadHook("<% $onload |n %>");
+    doOnLoad(<% $onload |n %>);
 % }
 --></script>

Modified: rt/3.8/trunk/share/html/NoAuth/js/util.js
==============================================================================
--- rt/3.8/trunk/share/html/NoAuth/js/util.js	(original)
+++ rt/3.8/trunk/share/html/NoAuth/js/util.js	Tue Aug  5 11:45:01 2008
@@ -143,6 +143,9 @@
 
 
 /* onload handlers */
+/* New code should be using doOnLoad which makes use of prototype
+   instead. See HeaderJavascript.  It works better than clobbering
+   window.onload.  Left around in case other code is using them */
 
 var onLoadStack     = new Array();
 var onLoadLastStack = new Array();
@@ -180,6 +183,12 @@
 
 window.onload = doOnLoadHooks;
 
+/* new onLoad code */
+
+function doOnLoad(handler) {
+    Event.observe(window, 'load', handler);
+}
+
 /* calendar functions */
 
 function openCalWindow(field) {


More information about the Rt-commit mailing list