diff --git a/app/assets/javascripts/behaviors/toggle_diff_line_wrap_behavior.coffee b/app/assets/javascripts/behaviors/toggle_diff_line_wrap_behavior.coffee new file mode 100644 index 0000000000000000000000000000000000000000..691ed4f98aeaee5f8db47b0dea943507cd22655d --- /dev/null +++ b/app/assets/javascripts/behaviors/toggle_diff_line_wrap_behavior.coffee @@ -0,0 +1,14 @@ +$ -> + # Toggle line wrapping in diff. + # + # %div.diff-file + # %input.js-toggle-diff-line-wrap + # %td.line_content + # + $("body").on "click", ".js-toggle-diff-line-wrap", (e) -> + diffFile = $(@).closest(".diff-file") + if $(@).is(":checked") + diffFile.addClass("diff-wrap-lines") + else + diffFile.removeClass("diff-wrap-lines") + diff --git a/app/assets/stylesheets/sections/diff.scss b/app/assets/stylesheets/sections/diff.scss index 488d06919b020fbed3ae4992fade70d809c51cd3..758f15c8013e0ac0502fec4fc3cf54bcda2a2b4c 100644 --- a/app/assets/stylesheets/sections/diff.scss +++ b/app/assets/stylesheets/sections/diff.scss @@ -125,8 +125,6 @@ } .line_content { display: block; - white-space: pre; - height: 18px; margin: 0px; padding: 0px 0.5em; border: none; @@ -341,3 +339,12 @@ margin: 0; border: none; } + +.diff-file .line_content { + white-space: pre; +} + +.diff-wrap-lines .line_content { + white-space: pre-wrap; +} + diff --git a/app/views/projects/commits/_diff_file.html.haml b/app/views/projects/commits/_diff_file.html.haml index 6e6107c88493af7d140d13b6a8746f8f9d5d940d..31208a227ce81c3a306d4330cfa3c59929daa958 100644 --- a/app/views/projects/commits/_diff_file.html.haml +++ b/app/views/projects/commits/_diff_file.html.haml @@ -16,6 +16,10 @@ %span.file-mode= "#{diff.a_mode} → #{diff.b_mode}" .diff-btn-group + %label + = check_box_tag nil, 1, false, class: "js-toggle-diff-line-wrap" + Wrap text + = link_to "#", class: "js-toggle-diff-comments btn btn-small" do %i.icon-chevron-down Diff comments