Oeyvind Brandtsegg

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromOeyvind Brandtsegg
ToMe
SubjectcollapsibleList Thanks and question about table
Date29 June 2007 10:13
[http://www.howtocreate.co.uk/jslibs/script-collapsiblelist]
Like this:

List item 1
  List item 1.1
     List item 1.1.2 ... has a lot of text and
     it wraps around and aligns nicely.

I have tried using tables inside the myList.sub calls like this:
myList.sub[0].sub[0] = new sub('<table><tr><td
width="70">&nbsp</td><td>*
blablabla</td></tr><tr><td>&nbsp</td></tr></table>');

This will give me control over indentation for multiline list items,
but I get and extra blank line at the top of the table. If I was using
this on the example above it would look like :

List item 1
  List item 1.1

     List item 1.1.2 ... has a lot of text and
     it wraps around and aligns nicely.

With an extra line before item 1.1.2

How could I use multiline text for list items and still have a compact
looking list without extra blank lines ?

very best
Oeyvind Brandtsegg
FromOeyvind Brandtsegg
ToMe
SubjectRe: collapsibleList Thanks and question about table
Date29 June 2007 12:25
...And I forgot to ask one more question:

Is it possible to "expand all" or even better "expand all lowest
level" branches (the ones that does not have any further links) with
the collapsibleList script.

I read a previous email about doing it with the nested lists script
but I'm unsure if the same method applies to the collapsible lists.

very best and thanks
Oeyvind Brandtsegg
FromMe
ToOeyvind Brandtsegg
SubjectRe: collapsibleList Thanks and question about table
Date23 June 2007 13:28
Oeyvind,

> How could I use multiline text for list items and still have a compact
> looking list without extra blank lines ?

Unfortunately, the script is not designed to be used this way. It expects
all lines to be the same height - the height of the images that you use.
This cannot be changed, I am afraid, as the script was not designed to be
used the way you want.

As far as tables are concerned, the script wraps the contents in paragraphs
and spans, neither of which are allowed to contain tables. If you use
tables, you will be relying on browser error handling to render anything at
all. The hack will fail in many browsers, especially if you use a doctype
that triggers strict rendering mode. The result would be a list that cannot
expand or collapse correctly.

> Is it possible to "expand all" or even better "expand all lowest
> level" branches (the ones that does not have any further links) with
> the collapsibleList script.

It should be possible to expand/collapse all. Unfortunately, this script
uses very messy HTML (the nested list collapsing script is far better), so
it is much harder to get a reliable reference to all the required links and
spans. I warn you that this is an ugly hack:

function excol(oNum,oExpand) {
 var foo = document.getElementById('treeList_'+oNum);
 var bar = foo.getElementsByTagName('span');
 for( var i = 0; i < bar.length; i++ ) {
  if( bar[i].id && bar[i].id.indexOf('treeList_') == 0 &&
    ( ( oExpand && bar[i].style.display == 'none' ) ||
    ( !oExpand && bar[i].style.display != 'none' ) ) ) {
   document.images[bar[i].id+'_img'].parentNode.onclick();
  }
 }
}

Works only on lists that are not set to auto-collapse. Call it like this:

excol(0,true); //expand all branches on the first list on the page
excol(2,false); //collapse all branches on the third list on the page

Sorry, but this is the best you can hope for with this script. It is not
really flexible enough to do the other things you want.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromOeyvind Brandtsegg
ToMe
SubjectRe: collapsibleList Thanks and question about table
Date30 June 2007 11:17
Thanks a lot for the clear answers.
I will look into the nested list script too.
And thanks for the large amount of well-tested scripts.

Oeyvind
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.