summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2020-12-10 17:19:18 +0100
committerGitHub <noreply@github.com>2020-12-10 17:19:18 +0100
commit1cb1fb8a2e86cc66a3f40f24d6f831eec90daba5 (patch)
tree43cc516c92e376f1d039226d3c026e21f91b8c7b /web_src
parentbc1cf6e5d365265d18144a2afae25ca04df691b8 (diff)
downloadgitea-1cb1fb8a2e86cc66a3f40f24d6f831eec90daba5.tar.gz
gitea-1cb1fb8a2e86cc66a3f40f24d6f831eec90daba5.zip
Remove JS globals related to timetracking and due date (#13921)
Refactor to avoid these globals. Should work exactly as before.
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js53
1 files changed, 29 insertions, 24 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 0dc0a9273b..55cf08cb61 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -1,5 +1,4 @@
-/* exported timeAddManual, toggleStopwatch, cancelStopwatch */
-/* exported toggleDeadlineForm, setDeadline, updateDeadline, deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */
+/* exported deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */
import './publicpath.js';
@@ -2525,6 +2524,8 @@ $(document).ready(async () => {
initU2FAuth();
initU2FRegister();
initIssueList();
+ initIssueTimetracking();
+ initIssueDue();
initWipTitle();
initPullRequestReview();
initRepoStatusChecker();
@@ -3105,22 +3106,22 @@ function initVueApp() {
});
}
-window.timeAddManual = function () {
- $('.mini.modal')
- .modal({
+function initIssueTimetracking() {
+ $(document).on('click', '.issue-add-time', () => {
+ $('.mini.modal').modal({
duration: 200,
onApprove() {
$('#add_time_manual_form').trigger('submit');
}
}).modal('show');
-};
-
-window.toggleStopwatch = function () {
- $('#toggle_stopwatch_form').trigger('submit');
-};
-window.cancelStopwatch = function () {
- $('#cancel_stopwatch_form').trigger('submit');
-};
+ });
+ $(document).on('click', '.issue-start-time, .issue-stop-time', () => {
+ $('#toggle_stopwatch_form').trigger('submit');
+ });
+ $(document).on('click', '.issue-cancel-time', () => {
+ $('#cancel_stopwatch_form').trigger('submit');
+ });
+}
function initFilterBranchTagDropdown(selector) {
$(selector).each(function () {
@@ -3476,16 +3477,7 @@ function initTopicbar() {
});
}
-window.toggleDeadlineForm = function () {
- $('#deadlineForm').fadeToggle(150);
-};
-
-window.setDeadline = function () {
- const deadline = $('#deadlineDate').val();
- window.updateDeadline(deadline);
-};
-
-window.updateDeadline = function (deadlineString) {
+function updateDeadline(deadlineString) {
$('#deadline-err-invalid-date').hide();
$('#deadline-loader').addClass('loading');
@@ -3519,7 +3511,20 @@ window.updateDeadline = function (deadlineString) {
$('#deadline-err-invalid-date').show();
}
});
-};
+}
+
+function initIssueDue() {
+ $(document).on('click', '.issue-due-edit', () => {
+ $('#deadlineForm').fadeToggle(150);
+ });
+ $(document).on('click', '.issue-due-remove', () => {
+ updateDeadline('');
+ });
+ $(document).on('submit', '.issue-due-form', () => {
+ updateDeadline($('#deadlineDate').val());
+ return false;
+ });
+}
window.deleteDependencyModal = function (id, type) {
$('.remove-dependency')