Mac OS X's Finder features a nifty NeXT throwback - the column view. This lets you browse through a hierarchy of files in a relatively compact space, and still see your path through directory structure.
Ok already, just show me the downloads!

There are a couple of jQuery plugins in the archive that claim to do this, but none really fit my core needs:
- The script should be unobtrusive, and let you transform a hierarchy of unordered lists of links (like a Drupal menu) into a column view, without requiring altering the underlying markup.
- The script shouldn't require a bunch of support files - css, images, etc.
- The output should work basically like a Finder list view - allow keyboard navigation with arrow keys, show when items have submenus (i.e. differentiate between "folders" and "files").
I think I've achieved two out of three - keyboard navigation doesn't seem to work in Webkit browsers (Safari and Chrome), and I got lazy and used the excellent Livequery plugin rather than rebinding events - but otherwise, it transforms this:
Into this:
Usage is pretty basic:
$('#columnized').columnview();
There are no options. The aesthetics and behavior of the menu are determined by overriding the CSS that it provides, and providing a double-click handler.
The script provides few CSS classes that can be overridden to change the way the script is displayed.
/*Top level container - set the width, height and border here*/
.containerobj {
border: 1px solid #ccc;
height:5em;
overflow-x:auto;
overflow-y:hidden;
white-space:nowrap;
}
/*Div containing an individual level of the menu hierarchy*/
.containerobj div {
height:100%;
overflow-y:scroll;
overflow-x:hidden;
float:left;
min-width:150px;
}
/*Link*/
.containerobj a {
display:block;
clear:both;
white-space:nowrap;
}
.containerobj a canvas{
padding-left:1em;
}
/*A bottom-level element (the furthest down in the hierarchy) is displayed as a
link, but could be overriden*/
.containerobj .feature {
min-width:200px;
}
.containerobj .feature a {
white-space:normal;
}
/*If you want to display links as folders vs. files, you can apply styles to the
.hasChildMenu class*/
.containerobj .hasChildMenu {
}
.containerobj .active {
background-color:#3671cf;
color:#fff;
}
/*You can override the color of the triangles here*/
.containerobj .hasChildMenu .widget{
color:black;
float:right;
text-decoration:none;
font-size:0.7em;
}
I chose to include these styles in the script rather than as an external file to avoid having to reference external files and worry about their placement on the server.
I should note that instead of including images for the little triangle widgets, I'm using Canvas to draw them, where available. Where it's not (in Internet Explorer), I put in a little ASCII triangle. I have to admit I did this as much to play around with Canvas as anything else.
To actually do something with the menu, I chose to use double-clicks, in keeping with the OS X style UI. Here's a sample handler:
$('#columnize a').livequery('dblclick',function(){
window.location = $(this).attr('href');
}
When I have time, I'll probably post up a demo page with some other examples of how to style the menu. In the meantime, you can download the script here:
For jQuery 1.2.x (requires Live Query plugin):
jquery.columnview-1.0.1.js [source]
jquery.columnview-1.0.1.min.js [minified]
For jQuery 1.3.x:
jquery.columnview-1.1.1.js [source]
jquery.columnview-1.1.1.min.js [minified]
Note: I have only tested this with jQuery 1.2.6, though I'd expect it to work with 1.3.x as well. Of course, 1.3 includes the live() method, which might be used in place of LiveQuery. For now, I'm focusing on 1.2.6, as this is what I'm running with all of my Drupal installations.
Update: I've updated the script to work with 1.3.x (tested against 1.3.2) and removed the dependency on the Live Query plugin. We're using the live() method now. Downloads added above.
I've tested this script in Safari 3.x and 4.x, Chrome, Firefox 3.x, and IE 6 and 7. As previously noted, keyboard navigation doesn't work yet in Safari and Chrome, and due to silly IE css handling, the width of submenus is fixed (via css) at 200px rather than shrinking to fit the content.
Update: The latest version of Columnview now supports jQuery version 1.2.x, 1.3.x and 1.4.x. Additionally, keyboard navigation is now available on all browsers when using jQuery 1.3 or later. The Livequery plugin is no longer required, but keyboard navigation is not supported with jQuery 1.2 (at the moment).
Update 19 April 2010: New features added to Columnview
- Added control/command- and shift- select options. Shift-select requires jQuery 1.4.x. Multi-selection is disabled by default, but you can enable it in two ways:
- When calling the method:
$("yourselector").columnview({multi:true});
- Prior to calling the columnview method:
$.fn.columnview.defaults.multi = true;
$("yourselector").columnview();
- Now assigning ID of original hierarchical object to columnview object, to allow easier styling, etc. Old object is reassigned to ID-processed and hidden.
- Fixed assignment of active/inpath classes so that only items that are currently selected have class=active.
Recent comments
6 days 18 hours ago
6 days 20 hours ago
1 week 7 hours ago
2 weeks 1 day ago
2 weeks 1 day ago
3 weeks 4 days ago
3 weeks 4 days ago
6 weeks 5 days ago
6 weeks 5 days ago
6 weeks 5 days ago