« Base jumping... with a wing-suitLyceum blog list widget »

3 comments

  1. § Joan Junyent said on :
    I think jqTOC is a great plugin. I’m currently using it in my blog to display a TOC for my articles.

    Just a small suggestion…

    It would be great if it would only display the TOC when it’s needed. I mean, if there are no subheaders then syle:none is aplyed to the toc_container so it doesn’t show up.

    I made a small and dirty hack to implement it on my blog but i thing it may be useful to include this functionality in the main script.

    The hack only works for my site structure but it should be hard to make it fully portable (there’s only need to replace the .entry-content reference with some independent reference).

    // create the main content container if not already created
    if (document.getElementById(settings.tocContainer) == null)
    $(’body’).append(’

    ‘);
    // START HACK: Checking if TOC is needed
    if ( ($(’h'+settings.tocStart).parent(”.entry-content”)).length ) {
    // END HACK: If it is needed then continue the script

    if (settings.tocTopLink) {
    $(’.toc_top’).bind(’click’, function(){window.scrollTo(0,0);});
    }
    }
    // If TOC is not needed then apply display: none to tocContainer
    else {
    $(’#'+settings.tocContainer).css(’display’,'none’);
    }
    // End of modifications
    return this;

    I hope it helps
  2. § Bruce Email said on :
    If I'm reading the code (and behavior) right, there's one problem I'm running into, and that is the assumption that headings are only ever immediate children of the containing element. But I'm needing a ToC for a document where every heading is wrapped in a div with a "section" class attribute. So, the headings are actually often grand-children of the container element.

    Any chance you can change the plug-in to more flexible on this count? Or any other suggestions?
  3. § DaveG Email said on :
    @Bruce: Interesting -- I've not hit that case before. I'll try and take a look at it shortly.

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
Originaly designed and iconized by N.Design Studio. Ported to b2evolution by Tender Feelings