diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html index a9658bb..e2a4868 100644 --- a/pagure/templates/pull_request.html +++ b/pagure/templates/pull_request.html @@ -390,40 +390,46 @@ {% endif %} - -{% if authenticated and mergeform and pull_request %} - - {{ mergeform.csrf_token }} - - Add new comment - (supports the Markdown syntax) - - - - Comment - Preview - - - - - - - - - - - + + + + + {% if authenticated and mergeform and pull_request %} + + + + {{ mergeform.csrf_token }} + + + Add new comment + + Preview + + + + + + + + + + + + + + + {% else %} + Login to comment on this ticket. + {% endif %} + + - -{% elif pull_request %} - Login to comment. -{% endif %} - @@ -574,6 +580,42 @@ } ); + $( "#preview" ).hide(); + $( "#previewinmarkdown" ).click( + function(event, ui) { + if ($( "#previewinmarkdown" ).hasClass("inactive")){ + var _text = $( "#comment" ).val(); + var _url = "{{ url_for('markdown_preview') }}"; + $.ajax({ + url: _url , + type: 'POST', + data: { + content: _text, + csrf_token: "{{ mergeform.csrf_token.current_token }}", + }, + dataType: 'html', + success: function(res) { + $( "#preview" ).html(res); + $( "#previewinmarkdown" ).removeClass("inactive"); + $( "#previewinmarkdown" ).addClass("active"); + $( "#comment" ).hide(); + $( "#preview" ).show(); + }, + error: function() { + alert('Unable to generate preview!'); + } + }); + return false; + } else if ($( "#previewinmarkdown" ).hasClass("active")){ + $( "#previewinmarkdown" ).addClass("inactive"); + $( "#previewinmarkdown" ).removeClass("active"); + $( "#comment" ).show(); + $( "#preview" ).hide(); + } + } + ); + + $(".edit_btn").click(function() { var commentid = $( this ).attr('data-comment'); var _url = '{{ request.base_url }}' + '/comment/' + commentid + '/edit';
Login to comment on this ticket.
Login to comment.