PDA

View Full Version : Smart folding menu tree & extra icons



Carolien
09-05-2004, 12:23 PM
Smart folding menu (http://dynamicdrive.com/dynamicindex1/navigate1.htm)

I am trying to add some more icons to the different subfolders to make the menu more intuitive, but I guess there are things that need to be added to this part of the script:

<style>
<!--
#foldheader{cursor:pointer;cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}

//-->
</style>
<script language="JavaScript1.2">
<!--

//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use

var head="display:''"
img1=new Image()
img1.src="fold.gif"
img2=new Image()
img2.src="open.gif"

var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
cur.style.listStyleImage="url(open.gif)"
}
else{
foldercontent.style.display="none"
cur.style.listStyleImage="url(fold.gif)"
}
}
}

if (ie4||ns6)
document.onclick=checkcontained

//-->
</script>

Can someone give me a hand in this?
TIA,
Carolien

cr3ative
09-05-2004, 12:35 PM
By more icons, do you mean different icons or just several icons on one line?

For my website I use TreeView (www.treeview.net), you can set different icons for different file types and the script is very flexible.

click here for an offical demo (http://www.treeview.net/treemenu/3fr_beenthere.html)

click here for a demonstration on my website (login=dynamicdrive) (http://www.afpsupport.r8.org/access/)

cr3ative

Carolien
09-05-2004, 03:11 PM
No, I meant different icons for different folders, even different icons for every seperate <li> if possible.
I first wanted to use a script that was similar to the one you describe, but since part of the tree is dynamicly built using php, I found it too hard to incorporate that in the js part, so I turned to the DD script.
Best,
Carolien

cr3ative
09-05-2004, 07:04 PM
You could try disabling icons altogether and inserting different icons where you input the text using <img src='filename'>, but this script only has 2 icons; one for each level. edit: you can customize each icon using CSS as described below.

cr3ative

ddadmin
09-06-2004, 07:05 PM
It's possible to apply a different folder image to a specific sublist item by using CSS. The main code to edit is the code of Step 3:


<font face="Verdana">

<ul>
<li id="foldheader">News</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<li><a href="http://www.cnn.com">CNN</a></li>
<li><a href="http://www.abcnews.com">ABC News</a></li>
<li><a href="http://www.news.bbc.co.uk">BBC News</a></li>
</ul>

<li id="foldheader">Webmaster</li>
<ul id="foldinglist" style="display:none" style=&{head};>
<li><a href="http://www.dynamicdrive.com" style="list-style-image:url(test.gif)">Dynamic Drive</a></li>
<li><a href="http://www.javascriptkit.com">JavaScript Kit</a></li>
<li><a href="http://www.freewarejava.com">Freewarejava.com</a></li>
</ul>

</font>

The code in red illustrates this. You may want to put it in a CSS class instead to easily apply the definition to muliple list items.

Carolien
09-12-2004, 02:09 PM
OK, I will give that a try, thanks for answering.