From 7484bcfff7fc8e132d94701b3af47f521ce117c5 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Mon, 18 Jun 2012 17:52:16 -0400 Subject: [PATCH 1/3] Invert "unless .empty?" to "if .present?"; unless-else is evil. --- app/views/merge_requests/_commits.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/merge_requests/_commits.html.haml b/app/views/merge_requests/_commits.html.haml index 441a7f32ef4..49c8e8cd77d 100644 --- a/app/views/merge_requests/_commits.html.haml +++ b/app/views/merge_requests/_commits.html.haml @@ -1,4 +1,4 @@ -- unless @commits.empty? +- if @commits.present? .ui-box %h5 Commits (#{@commits.count}) .merge-request-commits -- GitLab From 5b1ede628065ecfdf95552322328b5bb7613753a Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Mon, 18 Jun 2012 18:36:25 -0400 Subject: [PATCH 2/3] Handle MR "show all commits" 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/merge_requests.js | 13 +++++++------ app/views/merge_requests/_commits.html.haml | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/merge_requests.js b/app/assets/javascripts/merge_requests.js index c075cb4c0a3..9a18f335559 100644 --- a/app/assets/javascripts/merge_requests.js +++ b/app/assets/javascripts/merge_requests.js @@ -58,15 +58,16 @@ var MergeRequest = { dataType: "script"}); }, - showAllCommits: - function() { - $(".first_mr_commits").remove(); - $(".all_mr_commits").removeClass("hide"); - }, - already_cannot_be_merged: function(){ $(".automerge_widget").hide(); $(".automerge_widget.already_cannot_be_merged").show(); } } + +$(function () { + $('.first_mr_commits a.show_all').live('click', function() { + $(".first_mr_commits").remove(); + $(".all_mr_commits").removeClass("hide"); + }); +}); diff --git a/app/views/merge_requests/_commits.html.haml b/app/views/merge_requests/_commits.html.haml index 49c8e8cd77d..ad3cba2b822 100644 --- a/app/views/merge_requests/_commits.html.haml +++ b/app/views/merge_requests/_commits.html.haml @@ -9,7 +9,7 @@ %li.bottom 8 of #{@commits.count} commits displayed. %strong - = link_to_function "Click here to show all", "MergeRequest.showAllCommits()" + %a.show_all Click here to show all %ul.all_mr_commits.hide.unstyled - @commits.each do |commit| = render "commits/commit", :commit => commit -- GitLab From ef1598b4afa94b21db7f38755182a701d03ae44a Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Wed, 20 Jun 2012 11:11:17 -0400 Subject: [PATCH 3/3] 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 | 5 ----- app/assets/javascripts/commits.js | 7 +++++++ app/views/commits/_text_file.html.haml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0af0b11a931..bc91c9730ec 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -75,11 +75,6 @@ function slugify(text) { return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); } -function showDiff(link) { - $(link).next('table').show(); - $(link).remove(); -} - (function($){ var _chosen = $.fn.chosen; $.fn.extend({ diff --git a/app/assets/javascripts/commits.js b/app/assets/javascripts/commits.js index b31fe485896..5afac8c32c3 100644 --- a/app/assets/javascripts/commits.js +++ b/app/assets/javascripts/commits.js @@ -57,3 +57,10 @@ var CommitsList = { }); } } + +$(function () { + $('a.supp_diff_link').live('click', function() { + $(link).next('table').show(); + $(link).remove(); + }); +}); diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index e5173b00ed7..fa3d83ca85d 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -1,6 +1,6 @@ - too_big = max_lines = diff.diff.lines.count > 1000 - if too_big - = link_to_function "Diff suppressed. Click to show", "showDiff(this)", :class => "supp_diff_link" + %a.supp_diff_link Diff suppressed. Click to show %table{:class => "#{'hide' if too_big}"} - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| -- GitLab