Commit 7a139bf Let the reply button append instead of replacing

2 files Authored and Committed by pingou 7 days ago
Let the reply button append instead of replacing

This ensure that if you have something in the comment area, clicking
on the reply button won't delete it, it will just append the citation
after your text.

Fixes https://pagure.io/pagure/issue/3135

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>

    
 1 @@ -595,7 +595,11 @@
 2         for (cnt = 0; cnt < _text.length ; cnt ++) {
 3             _output[cnt] = '> ' + $.trim(_text[cnt]);
 4         }
 5 -       $( "#comment" ).val(_output.join("\n"));
 6 +       var _prev = $.trim($( "#comment" ).val());
 7 +       if (_prev.length > 0){
 8 +           _prev += "\n\n";
 9 +       }
10 +       $( "#comment" ).val(_prev + _output.join("\n"));
11       }
12     ).click(function(){
13       $('html, body').animate({
 1 @@ -1040,14 +1040,18 @@
 2     $(".reply").unbind();
 3     $( ".reply" ).click(
 4       function() {
 5 -       var _section = $(this).closest('.card-block');
 6 +       var _section = $(this).closest('.card-body');
 7         var _comment = _section.find('.comment_body');
 8         var _text = _comment.text().split("\n");
 9         var _output = new Array();
10         for (var cnt=0; cnt < _text.length; cnt++) {
11             _output[cnt] = '> ' + _text[cnt];
12         }
13 -       $( "#comment" ).val(_output.join("\n"));
14 +       var _prev = $.trim($( "#comment" ).val());
15 +       if (_prev.length > 0){
16 +           _prev += "\n\n";
17 +       }
18 +       $( "#comment" ).val(_prev + _output.join("\n"));
19       }
20     );
21   };