javascript/theme2.js
changeset 1 1ae1a79094fa
equal deleted inserted replaced
0:868dae1581ff 1:1ae1a79094fa
       
     1 $(document).ready(function(){
       
     2 
       
     3     // slide everything open on new page
       
     4     $(".outline:hidden").slideToggle("slow", function(){
       
     5         $(".percent:hidden").fadeIn("slow");
       
     6     });
       
     7 
       
     8     // re-activate links (the event is stomped on by the li event)
       
     9     $(".outline a").click(function(){ window.location.href = this });
       
    10 
       
    11     // highlight clicked items
       
    12     $("li").not("[ul]").click(function(){ $(this).toggleClass("selected") });
       
    13 
       
    14     // add line numbers
       
    15     var line_counter = 0;
       
    16     $("li").each(function(){
       
    17         var str = '<span class="linenum">' + ++line_counter + ':</span>';
       
    18         $(this).prepend(str);
       
    19     });
       
    20 
       
    21     // attach folds
       
    22     $(".outline ul li").toggle(
       
    23 
       
    24         // hide
       
    25         function(){
       
    26             if ( $(this).children("ul").size() == 0 ) return;
       
    27             $(this).children("ul").slideUp("slow");
       
    28             $(this).find(".linenum").addClass("linenum-folded");
       
    29         },
       
    30 
       
    31         // show
       
    32         function(){
       
    33             $(this).children("ul").slideDown("slow");
       
    34             $(this).find(".linenum").removeClass("linenum-folded");
       
    35         }
       
    36     );
       
    37 
       
    38 });