- i = 0
- block(:top_authors_of_yearmonth) do
  .blocktable
    %table
      %thead
        %th Year-Month
        %th Author
        %th Commits
        %th Total
      %tbody
        - stats.yearmonth_stats.sort{ |a, b| b[0] <=> a[0] }.each do |yearmonth, authorstats|
          - authors = authorstats.sort{ |a, b| b[1].commits <=> a[1].commits }[0, top_author_count]
          - authors.each do |author|
            - c = author[1].commits
            - first = author == authors.first
            - i += 1 if first
            %tr{:class => first ? 'top' : "yearmonthauthor_sub#{i}"}
              %td{:class => first ? "yearmonthauthor_top#{i}" : ""}&= first ? yearmonth : ''
              %td{:class => first ? "yearmonthauthor_top#{i}" : ""}&= author[0]
              %td{:class => first ? "yearmonthauthor_top#{i}" : ""}&= '%d of %d (%.2f%%)' % [c, authorstats.commits.to_f, c * 100.0 / authorstats.commits.to_f]
              %td{:class => first ? "yearmonthauthor_top#{i}" : ""}&= first ? authorstats.count : ''
- for j in 1..i
  :javascript
    $(document).ready(function() {
      $(".yearmonthauthor_sub#{j}").hide();
      $(".yearmonthauthor_top#{j}").click(function() {
        $(".yearmonthauthor_sub#{j}").toggle();
        return false;
      });
    });