Index: openacs-4/packages/forums/www/resources/dynamic-comments.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/resources/dynamic-comments.js,v diff -u -r1.1 -r1.2 --- openacs-4/packages/forums/www/resources/dynamic-comments.js 27 Jan 2005 22:12:08 -0000 1.1 +++ openacs-4/packages/forums/www/resources/dynamic-comments.js 27 Jan 2005 22:36:53 -0000 1.2 @@ -27,10 +27,10 @@ // Get an element by ID in a portable manner function getid(id) { - if(document.all) - return document.all(id); - else if(document.getElementById) + if(document.getElementById) return document.getElementById(id); + else if(document.all) + return document.all(id); return false; } @@ -60,21 +60,30 @@ var content = getid('content'+n); if(!link || !content || !ifrmdoc) return; + // Initialise the link's expandStatus if it hasn't yet been set - if(link.expandStatus == null) { - if(content.className == 'dynexpanded') - link.expandStatus = 1; - else - link.expandStatus = 0; - } + if(link.className == '') { + if (content.className == 'dynexpanded') { + link.className = 'dynexpanded'; + } else { + link.className = 'dyncollapsed'; + } + } + if(link.className == 'dynexpanded') { + link.expandStatus = 1; + } else { + link.expandStatus = 0; + } + var s; - if(state != null) - s = state; - else if(!link.expandStatus) - s = 1; // set to expand - else - s = 0; // set to collapse + if(state != null) + s = state; + else if(link.className == 'dyncollapsed') + s = 1; // set to expand + else + s = 0; // set to collapse + // Immediately return if we aren't changing state at all if((s == link.expandStatus) && (rate == null)) return; @@ -86,7 +95,6 @@ || ((s == 0) && content.collapsedContent))) { // If we've already grabbed the desired state for this comment, // set it right here - setSavedState(n, s); } else { @@ -185,15 +193,19 @@ var symbol; if (s) symbol = collapse_symbol; else symbol = expand_symbol; + if(link.innerHTML) link.innerHTML = symbol; else if(link.appendChild) { while(link.hasChildNodes()) link.removeChild(link.firstChild); link.appendChild(document.createTextNode(symbol)); } + link.expandStatus = s; + content.className = (s? 'dynexpanded' : 'dyncollapsed'); + link.className = (s? 'dynexpanded' : 'dyncollapsed'); } // Called from the iframe's onload event to ship the content into the main