So I needed a method to take a long, nested list and turning it into a compact, multiple acolumn list, in order to display it as sort of a site map for the home page for a site I'm working on.
Being a huge fan of jQuery, it was naturally my go-to library of choice.
Scanning the plugins site, I found a possible solution from a feller called Ingo Schommer called columnizeList.
Score, right? Well... not exactly, at least for my case.
Ingo used some of the methodoligies outlined in this article on multi-column lists on A List Apart. One of the caveats of his methodology is that each list item has to be the same height. This works Ok for a lot of use cases, but since I'm using a Drupal menu as the source for the list, it could contain arbitrary text I don't control.
So, I started from scratch. Instead of relying on consistent line heights, and applying different margin settings to list elements, I instead decided to decompose the large source list into several smaller lists (one for each column) and then use a css float parameter to make them all appear side-by-side.
Here's a sample list for a demonstration, cribbed from Ingo's example:
(apparently a list of the most common fillers for the middle initial in Jesus H. Christ)
Anyway, here's what my script does to the above list:
And here's the code:
There are only two parameters - cols, the number of columns to break the list into, and constrainWidth a boolean (defaulting to false) to specify whether you want all columns to be the same width.
I've tested with IE 6&7, FF3, Safari3 and Opera 9.something (for the three Opera users on the planet). The code could use a bit of refactoring perhaps for the purpose of beautification.



We spend lots of dough each year converting material from our dead-tree editions into web-friendlier versions for our web sites. We crank out a bunch of PDFs, and send them through the ether to somewhere where the labor is cheap and the workday long, like Vietnam, Indonesia or Canada or something. Then some poor soul slices 'n dices them into jpegs and links and such, and sends 'em on back, and posts them on our site.
So I thought to myself, "Self, you can do that without having to do something silly like use people and worse, pay for it.
It's a work in progress, but it goes something like...
Shazaam! $35k saved.
Not to mention, jquery almost makes coding javascript fun. Almost.


