javascript/theme2.js
author Mahlon E. Smith <mahlon@martini.nu>
Wed, 02 Dec 2009 17:07:11 -0800
changeset 5 75ab86f72a38
parent 1 1ae1a79094fa
permissions -rw-r--r--
... aaaand, revert the header line to reflect real paths, instead of what is live on martini.nu.

$(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");
        }
    );

});