javascript/theme2.js
author Mahlon E. Smith <mahlon@martini.nu>
Wed, 02 Dec 2009 17:00:38 -0800
changeset 4 4fe151fd3b80
parent 1 1ae1a79094fa
permissions -rw-r--r--
Update the sample to reflect 0.6's changes.

$(document).ready(function(){

    // slide everything open on new page
    $(".outline:hidden").slideToggle("slow", function(){
        $(".percent:hidden").fadeIn("slow");
    });

    // re-activate links (the event is stomped on by the li event)
    $(".outline a").click(function(){ window.location.href = this });

    // highlight clicked items
    $("li").not("[ul]").click(function(){ $(this).toggleClass("selected") });

    // add line numbers
    var line_counter = 0;
    $("li").each(function(){
        var str = '<span class="linenum">' + ++line_counter + ':</span>';
        $(this).prepend(str);
    });

    // attach folds
    $(".outline ul li").toggle(

        // hide
        function(){
            if ( $(this).children("ul").size() == 0 ) return;
            $(this).children("ul").slideUp("slow");
            $(this).find(".linenum").addClass("linenum-folded");
        },

        // show
        function(){
            $(this).children("ul").slideDown("slow");
            $(this).find(".linenum").removeClass("linenum-folded");
        }
    );

});