show a file diff when click on it in the header stats

This commit is contained in:
Alexander Machehin 2015-04-01 19:22:40 +05:00
parent 146a5370c3
commit dd9c280d09
3 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,6 @@
$(document).ready ->
$(document).on 'click', '#diff_header .panel-body table a', ->
href = $(this).attr('href')
$(".diff_data.collapse#"+href.slice(1)+"_content").collapse('show')
return

View File

@ -39,6 +39,7 @@
//= require extra/scroller
//= require extra/fork
//= require extra/diff_chevrons
//= require extra/diff
//= require_self

View File

@ -3,12 +3,10 @@ module DiffHelper
MAX_LINES_WITHOUT_COLLAPSE = 50
def render_diff_stats(stats)
path = @pull.try(:id) ? polymorphic_path([@project, @pull]) : ''
res = ["<table class='table table-responsive boffset0'>"]
stats.each_with_index do |stat, ind|
res << "<tr>"
res << "<td>#{link_to stat.filename.rtruncate(120), "#{path}#diff-#{ind}"}</td>"
res << "<td>#{link_to stat.filename.rtruncate(120), "#diff-#{ind}"}</td>"
res << "<td class='diffstat'>"
res << I18n.t("layout.projects.inline_changes_count", count: stat.additions + stat.deletions).strip +
" (" +