Edgewall Software

Ticket #7055: hide_annotation_columns-r6692.2.diff

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

Cleaned-up version, feature is now also enabled for attachments

  • trac/htdocs/css/code.css

    # HG changeset patch
    # User Christian Boos <cboos@neuf.fr>
    # Date 1206710774 -3600
    # Node ID 200f6429e7db6a8c9df028bf061b5b593fae3b0d
    # 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: #f7f7f7; 
     43 border-left: 1px solid; 
     44 border-right: 1px solid; 
     45 cursor: pointer; 
     46 margin: 0 1em 0 0; 
     47 padding: 0 .5em; 
    3748} 
    3849table.code tbody th { 
    3950 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] | <- c_h_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    // column headers 
     37    var c_h_row = $('thead tr', this); 
     38    var column_headers = $('th', c_h_row).not(recovery_area); 
     39    var k = column_headers.length; 
     40    // row headers 
     41    var tbody = $('tbody', this); 
     42    var row_headers = $('th', tbody); 
     43    var rows = $('tr', tbody); 
     44    var n = row_headers.length / k; 
     45 
     46    // add a 'hide' callback to each column header 
     47    column_headers.each(function(j) { 
     48        function hide() { 
     49          // remove and save column j 
     50          var th = $(this); 
     51          var ths = Array(n); 
     52          th.remove(); 
     53          for ( var i = 0; i < n; i++ ) 
     54            ths[i] = row_headers.eq(i*k+j).remove(); 
     55          // create a recovery button and its "show" callback 
     56          recovery_area.prepend($("<span></span>").addClass("recover") 
     57            .text("Show " + th.text()) 
     58            .click(function() { 
     59              $(this).remove(); 
     60              c_h_row.prepend(th.click(hide)); 
     61              $(ths).each(function(i){rows.eq(i).prepend(this);}); 
     62            }) 
     63          ); 
     64        }; 
     65        $(this).click(hide) 
     66          .css('cursor', 'pointer') 
     67          .attr('title', $(this).attr('title') + " (click to hide column)"); 
     68      }); 
     69  } 
     70 
     71})(jQuery); 
  • trac/templates/attachment.html

    diff --git a/trac/templates/attachment.html b/trac/templates/attachment.html
    a b  
    88  <xi:include href="macros.html" /> 
    99  <head> 
    1010    <title>Attachment</title> 
     11    <py:if test="preview"> 
     12      <script type="text/javascript" src="${chrome.htdocs_location}js/folding.js"></script> 
     13      <script type="text/javascript"> 
     14        jQuery(document).ready(function($) { 
     15          $('#preview table.code').enableCollapsibleColumns($('#preview table.code thead th.content'));  
     16        }); 
     17      </script> 
     18    </py:if> 
    1119  </head> 
    1220 
    1321  <body py:with="parent = attachments and attachments.parent or 
  • 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>