From 7a139bfcf9c89642dc4263f9ddb20a316a0dbd00 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 13 2018 08:25:32 +0000 Subject: 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 --- diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index c19fc39..1bfd757 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -595,7 +595,11 @@ function setup_reply_btns() { for (cnt = 0; cnt < _text.length ; cnt ++) { _output[cnt] = '> ' + $.trim(_text[cnt]); } - $( "#comment" ).val(_output.join("\n")); + var _prev = $.trim($( "#comment" ).val()); + if (_prev.length > 0){ + _prev += "\n\n"; + } + $( "#comment" ).val(_prev + _output.join("\n")); } ).click(function(){ $('html, body').animate({ diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index ebbac29..00cf0a0 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -1040,14 +1040,18 @@ function setup_reply_btns() { $(".reply").unbind(); $( ".reply" ).click( function() { - var _section = $(this).closest('.card-block'); + var _section = $(this).closest('.card-body'); var _comment = _section.find('.comment_body'); var _text = _comment.text().split("\n"); var _output = new Array(); for (var cnt=0; cnt < _text.length; cnt++) { _output[cnt] = '> ' + _text[cnt]; } - $( "#comment" ).val(_output.join("\n")); + var _prev = $.trim($( "#comment" ).val()); + if (_prev.length > 0){ + _prev += "\n\n"; + } + $( "#comment" ).val(_prev + _output.join("\n")); } ); };