Skip to content

Commit b4b0280

Browse files
jonasfranzlunny
authored andcommitted
Ctrl + Enter to submit forms (#2540)
* Hotfix for "Add time manually" (#2211 (comment)) Signed-off-by: Jonas Franz <[email protected]> * Submit forms if Ctrl+Enter is pressed inside a textarea Signed-off-by: Jonas Franz <[email protected]> * Adding separate class for Ctrl+Enter-Submit Checking if alt key is pressed too Signed-off-by: Jonas Franz <[email protected]> * Changing .ctrlenter to .js-quick-submit Signed-off-by: Jonas Franz <[email protected]>
1 parent 1be2b4a commit b4b0280

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

public/js/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,7 @@ $(document).ready(function () {
15791579
initCodeView();
15801580
initVueApp();
15811581
initTeamSettings();
1582+
initCtrlEnterSubmit();
15821583

15831584
// Repo clone url.
15841585
if ($('#repo-clone-url').length > 0) {
@@ -1786,6 +1787,14 @@ function initVueComponents(){
17861787
})
17871788
}
17881789

1790+
function initCtrlEnterSubmit() {
1791+
$(".js-quick-submit").keydown(function(e) {
1792+
if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
1793+
$(this).closest("form").submit();
1794+
}
1795+
});
1796+
}
1797+
17891798
function initVueApp() {
17901799
var el = document.getElementById('app');
17911800
if (!el) {

templates/repo/issue/comment_tab.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}">{{.i18n.Tr "repo.release.preview"}}</a>
55
</div>
66
<div class="ui bottom attached active tab segment" data-tab="write">
7-
<textarea id="content" class="edit_area" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.Repo.RepoLink}}">
7+
<textarea id="content" class="edit_area js-quick-submit" name="content" tabindex="4" data-id="issue-{{.RepoName}}" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.Repo.RepoLink}}">
88
{{if .IssueTemplate}}{{.IssueTemplate}}{{else if .PullRequestTemplate}}{{.PullRequestTemplate}}{{else}}{{.content}}{{end}}</textarea>
99
</div>
1010
<div class="ui bottom attached tab segment markdown" data-tab="preview">

0 commit comments

Comments
 (0)