diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 9a94959..9f0e55c 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -30,6 +30,7 @@ {% if authenticated and form %}
{{ form.csrf_token }} {% endif %} @@ -205,8 +206,6 @@ $(document).ready(function() { $("#file-picker").on("change", function() { doUpload("{{ form.csrf_token.current_token }}", this.files); }); - - }); {% endif %} @@ -355,6 +354,29 @@ source.addEventListener('message', function(e) { process_event(data, "{{ issue.uid }}", _issue_url, _issues_url); }, false); + +{% if authenticated and form %} +function try_async_comment(form) { + $.post( form.action + "?js=1", $(form).serialize() ) + .done(function(data) { + if(data == 'ok') { + {# The event-source server will automatically refresh the UI #} + $('#comment').val(''); + } else { + // Make the browser submit the form sync + $(form).off('submit'); + form.submit(); + } + }) + .fail(function() { + // Make the browser submit the form sync + $(form).off('submit'); + form.submit(); + }) + return false; +}; +{% endif %} + {% endif %}