[Rt-commit] r3458 - in rt/branches/3.5-TESTING: . html/Elements
html/NoAuth/js
trs at bestpractical.com
trs at bestpractical.com
Sat Jul 9 22:22:15 EDT 2005
Author: trs
Date: Sat Jul 9 22:22:14 2005
New Revision: 3458
Modified:
rt/branches/3.5-TESTING/ (props changed)
rt/branches/3.5-TESTING/html/Elements/Header
rt/branches/3.5-TESTING/html/NoAuth/js/util.js
Log:
r4973 at wintermute: tom | 2005-07-09 22:21:10 -0400
Added Robert's nice onload hook mechanism, though in the future we may wish to extend it to accepting anonymous functions as well.
Modified: rt/branches/3.5-TESTING/html/Elements/Header
==============================================================================
--- rt/branches/3.5-TESTING/html/Elements/Header (original)
+++ rt/branches/3.5-TESTING/html/Elements/Header Sat Jul 9 22:22:14 2005
@@ -60,9 +60,18 @@
% }
<script type="text/javascript" src="<%$RT::WebPath%>/NoAuth/js/util.js"></script>
<script type="text/javascript" src="<%$RT::WebPath%>/NoAuth/js/titlebox-state.js"></script>
+ <script type="text/javascript"><!--
+ onLoadHook("loadTitleBoxStates()");
+% if ($Focus) {
+ onLoadHook("focusElementById('<% $Focus %>')");
+% }
+% if ($onload) {
+ onLoadHook("<% $onload |n %>");
+% }
+ --></script>
<& /Elements/Callback, _CallbackName => 'Head', %ARGS &>
</head>
- <body onload="<% "$onload;" |n %><% $Focus && qq[ setFocus('$Focus');] |n %>loadTitleBoxStates();">
+ <body>
% if ($ShowBar) {
<div id="quickbar">
Modified: rt/branches/3.5-TESTING/html/NoAuth/js/util.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/util.js (original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/util.js Sat Jul 9 22:22:14 2005
@@ -61,7 +61,7 @@
return false;
}
-function setFocus(id) {
+function focusElementById(id) {
var e = document.getElementById(id);
if (e) e.focus();
}
@@ -70,3 +70,41 @@
var objWindow = window.open('<%$RT::WebPath%>/CalPopup.html?field='+field, 'Pick', 'height=400,width=400,scrollbars=1');
objWindow.focus();
}
+
+// onload handlers
+
+var onLoadStack = new Array();
+var onLoadLastStack = new Array();
+var onLoadExecuted = 0;
+
+function onLoadHook(commandStr) {
+ if(typeof(commandStr) == "string") {
+ onLoadStack[onLoadStack.length] = commandStr;
+ return true;
+ }
+ return false;
+}
+
+// some things *really* need to be done after everything else
+function onLoadLastHook(commandStr) {
+ if(typeof(commandStr) == "string"){
+ onLoadLastStack[onLoadLastStack.length] = commandStr;
+ return true;
+ }
+ return false;
+}
+
+function doOnLoadHooks() {
+ if(onLoadExecuted) return;
+
+ for (var x=0; x < onLoadStack.length; x++) {
+ eval(onLoadStack[x]);
+ }
+ for (var x=0; x < onLoadLastStack.length; x++) {
+ eval(onLoadLastStack[x]);
+ }
+ onLoadExecuted = 1;
+}
+
+window.onload = doOnLoadHooks;
+
More information about the Rt-commit
mailing list