Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent double click new issue/pull/comment button #16157

Merged
merged 12 commits into from
May 7, 2022
2 changes: 1 addition & 1 deletion templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</div>
{{template "repo/issue/comment_tab" .}}
<div class="text right">
<button class="ui green button" tabindex="6">
<button class="ui green button once-button" tabindex="6">
{{if .PageIsComparePull}}
{{.i18n.Tr "repo.pulls.create"}}
{{else}}
Expand Down
4 changes: 2 additions & 2 deletions templates/repo/issue/view_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
<button class="ui green button once-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>
Expand Down Expand Up @@ -159,7 +159,7 @@
</div>
{{end}}
{{end}}
<button class="ui green button" tabindex="5">
<button class="ui green button once-button" tabindex="5">
{{.i18n.Tr "repo.issues.create_comment"}}
</button>
</div>
Expand Down
11 changes: 11 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3959,3 +3959,14 @@ $(document).on('click', '.oauth-login-image', () => {
oauthNav.show();
}, 5000);
});

// once-button is the button which can be clicked only one time
$(document).on('click', '.button.once-button', function () {
const $btn = $(this);
$btn.addClass('loading clicked');
a1012112796 marked this conversation as resolved.
Show resolved Hide resolved
});

$(document).on('click', '.button.once-button.clicked', (e) => {
a1012112796 marked this conversation as resolved.
Show resolved Hide resolved
e.preventDefault();
lafriks marked this conversation as resolved.
Show resolved Hide resolved
return false;
a1012112796 marked this conversation as resolved.
Show resolved Hide resolved
});