Edgewall Software

Ticket #7055: hide_annotation_columns-r6692.diff

File hide_annotation_columns-r6692.diff, 3.7 KB (added by cboos, 10 months ago)

Expanding a bit on Ted Gifford's approach

  • trac/htdocs/css/code.css

    # HG changeset patch
    # User Christian Boos <cboos@neuf.fr>
    # Date 1206708016 -3600
    # Node ID 496e861169de079fc5e4fd723ecf1bb3f10d6b8e
    # Parent  fa5a3be904424e558dd86a3d9ecb4b6dc233e9ac
    Clicking on any annotation header column hides that column.
    
    Implements #7055
    
    diff --git a/trac/htdocs/css/code.css b/trac/htdocs/css/code.css
    a b  
    3434 padding: 0 .25em; 
    3535 text-align: center; 
    3636 white-space: nowrap; 
     37} 
     38table.code thead th.content { 
     39 text-align: left; 
     40} 
     41table.code thead th.content span.recover { 
     42 background: #f0f0f0; 
     43 margin: 0 1em; 
     44 padding: 0 .5em; 
    3745} 
    3846table.code tbody th { 
    3947 background: #eed; 
  • trac/htdocs/js/folding.js

    diff --git a/trac/htdocs/js/folding.js b/trac/htdocs/js/folding.js
    a b  
    2323    }).css("cursor", "pointer"); 
    2424  } 
    2525 
    26 })(jQuery); 
    27  No newline at end of file 
     26  /** Enable columns of a table to be hidden by clicking on the column header. 
     27   * 
     28   * +------------------+------+---- ... ---+---------------------+ 
     29   * |column_headers[0] | ...  |            | column_headers[k-1] | <- ch_row 
     30   * +==================+======+==== ... ===+=====================+ 
     31   * | row_headers[0]   | row_headers[1]    | row_headers[1*k-1]  | <- rows[0] 
     32   * | row_headers[k]   | row_headers[k+1]  | row_headers[2*k-1]  | <- rows[1] 
     33   * ... 
     34   */ 
     35  $.fn.enableCollapsibleColumns = function(recovery_area) { 
     36    var ch_row = $('thead tr', this); 
     37    var column_headers = $('thead th', this).not(recovery_area); 
     38    var row_headers = $('tbody th', this); 
     39    var rows = $('tbody tr', this); 
     40    var k = column_headers.length; 
     41    var n = row_headers.length / k; 
     42    $(column_headers).each(function(j) { 
     43        function hide() { 
     44          // remove and save column 
     45          var th = $(this); 
     46          var jj = j; // th.data('j'); 
     47          var ths = Array(n); 
     48          th.remove(); 
     49          for ( var i = 0; i < n; i++ ) 
     50            ths[i] = $(row_headers[i*k+jj]).remove(); 
     51          // create a recovery button and its "show" callback 
     52          recovery_area.append($("<span></span>").addClass("recover") 
     53            .text("Show " + th.text() + " Info") 
     54            .click(function() { 
     55              $(this).remove(); 
     56              ch_row.prepend(th.click(hide)); 
     57              $(ths).each(function(i){rows.eq(i).prepend(this);}); 
     58            }) 
     59          ); 
     60        }; 
     61        $(this).click(hide) 
     62          .attr('title', $(this).attr('title') + " (click to hide column)"); 
     63      }); 
     64  } 
     65 
     66})(jQuery); 
  • trac/versioncontrol/templates/browser.html

    diff --git a/trac/versioncontrol/templates/browser.html b/trac/versioncontrol/templates/browser.html
    a b  
    1010    <title>$path</title> 
    1111    <meta py:if="file and file.annotate" name="ROBOTS" content="NOINDEX, NOFOLLOW" /> 
    1212    <meta py:if="dir" name="ROBOTS" content="NOINDEX" /> 
     13    <script type="text/javascript" src="${chrome.htdocs_location}js/folding.js"></script> 
    1314    <script type="text/javascript"> 
    1415      jQuery(document).ready(function($) { 
    1516        $("#jumploc input").hide(); 
     
    2728                range_max_secs: '$dir.range_max_secs' 
    2829            }); 
    2930        </py:if> 
    30         <py:if test="file and file.annotate"> 
    31           enableBlame("${href.changeset()}/", "${path}"); 
     31        <py:if test="file"> 
     32          <py:if test="file.annotate"> 
     33            enableBlame("${href.changeset()}/", "${path}"); 
     34          </py:if> 
     35          $('#preview table.code').enableCollapsibleColumns($('#preview table.code thead th.content'));  
    3236        </py:if> 
    3337      }); 
    3438    </script>