Update of /cvsroot/thyapi/thyapi/thybase
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18601/thybase
Modified Files:
thybase.js
Log Message:
Commiting file additions and modification from SVN revision 2335 to 2336...
Changes made by rpereira on 2005-11-25 03:37:59 +0100 (Fri, 25 Nov 2005) corresponding to SVN revision 2336 with message:
- Added important dynapi.onClassLoad function
- Correct bugs
Index: thybase.js
===================================================================
RCS file: /cvsroot/thyapi/thyapi/thybase/thybase.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** thybase.js 1 Sep 2005 18:15:37 -0000 1.1
--- thybase.js 25 Nov 2005 01:55:08 -0000 1.2
***************
*** 231,232 ****
--- 231,286 ----
}
+ /**
+ * Function: dynapi.onClassLoad
+ *
+ * Runs script upon class load
+ *
+ * Parameters:
+ *
+ * className - The class name
+ * func - The function to be run
+ *
+ */
+ dynapi.onClassLoad = function (className, func)
+ {
+ if (window[className])
+ {
+ func();
+ return;
+ }
+
+ if (!dynapi.waitingLoad) dynapi.waitingLoad = {};
+
+ if (!dynapi.waitingLoad[className]) dynapi.waitingLoad[className] = [func];
+ else dynapi.waitingLoad[className].push(func);
+
+ if (!dynapi.waitingLoadInt)
+ dynapi.waitingLoadInt = setInterval(dynapi.waitingLoadFunc, 100);
+ }
+
+ dynapi.waitingLoadFunc = function()
+ {
+ var i,j;
+
+ for (i in dynapi.waitingLoad)
+ {
+ var funcs = dynapi.waitingLoad[i];
+ if (window[i])
+ {
+ for (j=0; j<funcs.length; j++)
+ funcs[j]();
+
+ funcs = null;
+ dynapi.waitingLoad[i] = null;
+ delete dynapi.waitingLoad[i];
+ }
+ }
+
+ var c = 0;
+ for (i in dynapi.waitingLoad)
+ {
+ c++;
+ }
+
+ if (!c) clearInterval(dynapi.waitingLoadInt);
+ }
|