Commit ef1598b4afa94b21db7f38755182a701d03ae44a

Authored by Robb Kidd
1 parent 5b1ede62

Handle Commit "show suppressed diff" link with a doc-ready event handler.

Replaces link_to_function use which was deprecated in Rails v3.2.4.
https://github.com/rails/rails/commit/9dc57fe9c

Still absent is a graceful degrade for no-JS.
app/assets/javascripts/application.js
... ... @@ -75,11 +75,6 @@ function slugify(text) {
75 75 return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase();
76 76 }
77 77  
78   -function showDiff(link) {
79   - $(link).next('table').show();
80   - $(link).remove();
81   -}
82   -
83 78 (function($){
84 79 var _chosen = $.fn.chosen;
85 80 $.fn.extend({
... ...
app/assets/javascripts/commits.js
... ... @@ -57,3 +57,10 @@ var CommitsList = {
57 57 });
58 58 }
59 59 }
  60 +
  61 +$(function () {
  62 + $('a.supp_diff_link').live('click', function() {
  63 + $(link).next('table').show();
  64 + $(link).remove();
  65 + });
  66 +});
... ...
app/views/commits/_text_file.html.haml
1 1 - too_big = max_lines = diff.diff.lines.count > 1000
2 2 - if too_big
3   - = link_to_function "Diff suppressed. Click to show", "showDiff(this)", :class => "supp_diff_link"
  3 + %a.supp_diff_link Diff suppressed. Click to show
4 4  
5 5 %table{:class => "#{'hide' if too_big}"}
6 6 - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old|
... ...