Browse Source

issue and pull request comment boxes: ctrl-key submits the form

Julen Landa Alustiza 4 years ago
parent
commit
f90c1c1f98
2 changed files with 27 additions and 0 deletions
  1. 12 0
      pagure/templates/issue.html
  2. 15 0
      pagure/templates/repo_pull_request.html

+ 12 - 0
pagure/templates/issue.html

@@ -1237,6 +1237,18 @@ $( "#previewinmarkdown" ).click(
     }
   );
 
+  function submitFormOnCtrlKey(event) {
+    if (event.ctrlKey && event.keyCode == 13) {
+      var form = event.target.form;
+      form.submit();
+      event.preventDefault();
+    }
+  }
+
+  $('#comment').keydown(function(e) {
+    submitFormOnCtrlKey(e);
+  });
+
 
   {% if g.authenticated and (
     g.repo_user

+ 15 - 0
pagure/templates/repo_pull_request.html

@@ -1016,6 +1016,21 @@ $(document).ready(function() {
     return try_async_comment($(this), false);
   })
 
+  function submitFormOnCtrlKey(event) {
+    if (event.ctrlKey && event.keyCode == 13) {
+      var form = event.target.form;
+      form.submit();
+      event.preventDefault();
+    }
+  }
+
+  $('#comment').keydown(function(e) {
+    submitFormOnCtrlKey(e);
+  });
+  $('#inline-comment').keydown(function(e) {
+    submitFormOnCtrlKey(e);
+  });
+
 {% if pull_request %}
 {# These lines are only for existing pull-requests, not new ones #}