Results 1 to 6 of 6

Thread: Smart folding menu tree & extra icons

  1. #1
    Join Date
    Sep 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Smart folding menu tree & extra icons

    Smart folding menu

    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{cursorointer;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

  2. #2
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

    click here for a demonstration on my website (login=dynamicdrive)

    cr3ative
    Last edited by cr3ative; 09-05-2004 at 11:45 AM. Reason: Chrnorder; Link was broken, added link to my site's demo, added treeview info.
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  3. #3
    Join Date
    Sep 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by cr3ative; 09-07-2004 at 01:29 PM. Reason: Incorrect information
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  5. #5
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    <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.

  6. #6
    Join Date
    Sep 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK, I will give that a try, thanks for answering.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •