From b4b0280e339767ae13ea994cee877a666255e65d Mon Sep 17 00:00:00 2001 From: Jonas Franz Date: Fri, 22 Sep 2017 08:17:31 +0200 Subject: [PATCH] Ctrl + Enter to submit forms (#2540) * Hotfix for "Add time manually" (https://github.com/go-gitea/gitea/pull/2211#issuecomment-328780125) Signed-off-by: Jonas Franz * Submit forms if Ctrl+Enter is pressed inside a textarea Signed-off-by: Jonas Franz * Adding separate class for Ctrl+Enter-Submit Checking if alt key is pressed too Signed-off-by: Jonas Franz * Changing .ctrlenter to .js-quick-submit Signed-off-by: Jonas Franz --- public/js/index.js | 9 +++++++++ templates/repo/issue/comment_tab.tmpl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index cded5e2a1a..c456395770 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1579,6 +1579,7 @@ $(document).ready(function () { initCodeView(); initVueApp(); initTeamSettings(); + initCtrlEnterSubmit(); // Repo clone url. if ($('#repo-clone-url').length > 0) { @@ -1786,6 +1787,14 @@ function initVueComponents(){ }) } +function initCtrlEnterSubmit() { + $(".js-quick-submit").keydown(function(e) { + if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) { + $(this).closest("form").submit(); + } + }); +} + function initVueApp() { var el = document.getElementById('app'); if (!el) { diff --git a/templates/repo/issue/comment_tab.tmpl b/templates/repo/issue/comment_tab.tmpl index 3af3d8a041..afdaa44c06 100644 --- a/templates/repo/issue/comment_tab.tmpl +++ b/templates/repo/issue/comment_tab.tmpl @@ -4,7 +4,7 @@ {{.i18n.Tr "repo.release.preview"}}
-
-- 2.39.5