PDA

View Full Version : put bold on Switch Content Script



mateus_reis
08-24-2006, 05:31 PM
1) Script Title: Switch Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

3) Describe problem:

How can I put bold on selected item? I want to put bold only at "curobj" selected... I try this code below, but it fails to reset non-current itens to normal after clicking...:




if (ccollect.length>0){
curobj.style.fontWeight=(curobj.style.fontWeight!="bold")? "bold" : "normal";
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none";
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

jscheuer1
08-25-2006, 04:46 PM
Well, it would depend upon how you are using the script. If you have collapseprevious set to 'yes' and are not using the optional expand all and contract all links or the persistence feature, it would be rather easy -

Put this function in the script:


function killBold(){
var inc=0
while (statecollect[inc]){
statecollect[inc].parentNode.style.fontWeight='normal'
inc++
}
}

and use this instead of the line you had added:


if (ccollect.length>0){
killBold();
curobj.style.fontWeight=document.getElementById(cid).style.display!="block"? "bold" : "normal";
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}