Index: openacs-4/packages/acs-templating/www/resources/mktree.js
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/mktree.js,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/acs-templating/www/resources/mktree.js 12 Apr 2005 14:37:09 -0000 1.1
+++ openacs-4/packages/acs-templating/www/resources/mktree.js 4 Jun 2006 00:45:48 -0000 1.2
@@ -32,6 +32,7 @@
// you to set the state of the tree when painting the page simply
// by setting some
's class name as being "liOpen" (see example)
// March 29, 2005: Added cookie-managed state (AG).
+// May 16, 2005: don't register 'convertTrees' multiple times (GN)
/*
This code is inspired by and extended from Stuart Langridge's aqlist code:
http://www.kryogenix.org/code/browser/aqlists/
@@ -42,15 +43,32 @@
*/
// Automatically attach a listener to the window onload, to convert the trees
-addEvent(window,"load",convertTrees);
+// Register the event only once. if registered multiple times, the items are rendered
+// with multiple + or - signs.... -gustaf neumann
+if (typeof mktree_registered == 'undefined') {
+ addEvent(window,"load",convertTrees);
+ var mktree_registered = 1;
+}
+
// Utility function to add an event listener
function addEvent(o,e,f){
if (o.addEventListener){ o.addEventListener(e,f,true); return true; }
else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
else { return false; }
}
+function removeEvent( obj, type, fn ) {
+ if (obj.removeEventListener) {
+ obj.removeEventListener( type, fn, false );
+ } else if (obj.detachEvent) {
+ obj.detachEvent( "on"+type, obj[type+fn] );
+ obj[type+fn] = null;
+ obj["e"+type+fn] = null;
+ }
+}
+
+
// utility function to set a global variable if it is not already set
function setDefault(name,val) {
if (typeof(window[name])=="undefined" || window[name]==null) {