Thanks for the code links. I didn't work on the positioning yet, but your samples will help. I did take a quick look, and the current absolute positioning is complicated here because the position of the TOC is dynamic based on the parameter'ed width. I'm not sure fixed positioning will be possible or not based on the changeable width.

I couldn't work out specifically why the old selector did not work, but I a quick search came up with a new style that seems to function fine, using .children(). If there's a better or more efficient selector, advice would be welcomed.

Here's the core of my updated version (link to full: http://solidgone.com/jquery/jqpagecontent.htm):

var t = $('#toc_content');
this.children().each(function(i) {
   var headerLevel = this.nodeName.substr(1,1);
if(this.nodeName.match(/^H\d+$/) && headerLevel >= settings.tocStart && headerLevel <= settings.tocEnd) {

      var headerId = this.id || 'link' + i;
      t.append('<a href="#'+ headerId +'" ' +
(headerLevel != settings.tocStart ? 'class="indent" style="margin-left: ' + (headerLevel-settings.tocStart)*15 +'px;"' : '') +
         '>'+ $(this).html() +'</a>');
      this.id = headerId;
   }
});

It adds two new settings, specifying the heading levels at which to start and stop building.

 ~ ~ Dave

Joel Birch wrote:

On 15/04/2007, at 6:39 AM, DaveG wrote:
Does anyone have any insight into what happened, or alternatively is
there an alternate TOC plugin somewhere?

I made a contentMenu plugin that does something very similar to this from what I can tell. Here is the basic code - sorry, no demo page or documentation but the code is very short and hopefully easy to understand.
http://users.tpg.com.au/j_birch/plugins/jquery.contentMenu.js

You can pass in options to specify where the menu (TOC) is injected into the document. With that in mind, inspired by a suggestion from Klaus Hartl, I have used this plugin to append the menu to the body element and set its position to 'fixed' so that it floats in place in the window similar to the TOC plugin you pointed to. I wrapped all this up in its own plugin called contentMenuDrawer and also used a whole bunch of other plugins to further enhance the functionality (scrollTo, hoverIntent, jqEm). If you want to do something similar, you can see this in action at the following url (content of the page is irrelevant to this topic).
http://users.tpg.com.au/j_birch/plugins/superfish/

The relevant code I used for this is here:
http://users.tpg.com.au/j_birch/plugins/superfish/demoPage.js
Everything in that file is relevant except for the bgIframe plugin which is used for an unrelated purpose.

I have not added fixed positioning support for IE6 so it fails silently in that browser. It should be easy to add support if you wanted to.

I just thought this may be of some use to you. Good luck.

Joel Birch.




Reply via email to