mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-18 11:59:27 +00:00
Remove usage of JS globals (#15378)
Refactor the exported globals in index.js to JS-initialized event handlers. Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
b9ed3cbc26
commit
216976247c
|
@ -44,7 +44,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if or (not $.HasComments) $.hidden}}
|
{{if or (not $.HasComments) $.hidden}}
|
||||||
<button type="button" class="ui submit tiny basic button btn-cancel" onclick="window.cancelCodeComment(this);">{{$.root.i18n.Tr "cancel"}}</button>
|
<button type="button" class="ui submit tiny basic button btn-cancel cancel-code-comment">{{$.root.i18n.Tr "cancel"}}</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -467,8 +467,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="item-right df ac">
|
<div class="item-right df ac">
|
||||||
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
||||||
<a class="delete-dependency-button poping up ci" onclick="window.deleteDependencyModal({{.Issue.ID}}, 'blocking');"
|
<a class="delete-dependency-button poping up ci" data-id="{{.Issue.ID}}" data-type="blocking" data-content="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
||||||
data-content="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
|
||||||
{{svg "octicon-trash" 16}}
|
{{svg "octicon-trash" 16}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -495,8 +494,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="item-right df ac">
|
<div class="item-right df ac">
|
||||||
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
{{if and $.CanCreateIssueDependencies (not $.Repository.IsArchived)}}
|
||||||
<a class="delete-dependency-button poping up ci" onclick="window.deleteDependencyModal({{.Issue.ID}}, 'blockedBy');"
|
<a class="delete-dependency-button poping up ci" data-id="{{.Issue.ID}}" data-type="blockedBy" data-content="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
||||||
data-content="{{$.i18n.Tr "repo.issues.dependency.remove_info"}}" data-inverted="">
|
|
||||||
{{svg "octicon-trash" 16}}
|
{{svg "octicon-trash" 16}}
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
{{if and .OrderedOAuth2Names .OAuth2Providers}}
|
{{if and .OrderedOAuth2Names .OAuth2Providers}}
|
||||||
<div class="ui attached segment">
|
<div class="ui attached segment">
|
||||||
<div class="oauth2 center">
|
<div class="oauth2 center">
|
||||||
<div id="oauth2-login-loader" class="ui disabled centered loader"></div>
|
<div id="oauth2-login-loader" class="ui disabled centered loader"></div>
|
||||||
<div>
|
<div>
|
||||||
<div id="oauth2-login-navigator">
|
<div id="oauth2-login-navigator">
|
||||||
<p>{{.i18n.Tr "sign_in_with"}}</p>
|
<p>{{.i18n.Tr "sign_in_with"}}</p>
|
||||||
|
@ -63,9 +63,8 @@
|
||||||
<img
|
<img
|
||||||
alt="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
|
alt="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
|
||||||
title="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
|
title="{{$provider.DisplayName}}{{if eq $provider.Name "openidConnect"}} ({{$key}}){{end}}"
|
||||||
class="{{$provider.Name}}"
|
class="{{$provider.Name}} oauth-login-image"
|
||||||
src="{{AppSubUrl}}{{$provider.Image}}"
|
src="{{AppSubUrl}}{{$provider.Image}}"
|
||||||
onclick="window.onOAuthLoginClick()"
|
|
||||||
></a>
|
></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
/* exported deleteDependencyModal, cancelCodeComment, onOAuthLoginClick */
|
|
||||||
|
|
||||||
import './publicpath.js';
|
import './publicpath.js';
|
||||||
|
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
@ -1156,6 +1154,32 @@ async function initRepository() {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Delete Issue dependency
|
||||||
|
$(document).on('click', '.delete-dependency-button', (e) => {
|
||||||
|
const {id, type} = e.currentTarget.dataset;
|
||||||
|
|
||||||
|
$('.remove-dependency').modal({
|
||||||
|
closable: false,
|
||||||
|
duration: 200,
|
||||||
|
onApprove: () => {
|
||||||
|
$('#removeDependencyID').val(id);
|
||||||
|
$('#dependencyType').val(type);
|
||||||
|
$('#removeDependencyForm').trigger('submit');
|
||||||
|
}
|
||||||
|
}).modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Cancel inline code comment
|
||||||
|
$(document).on('click', '.cancel-code-comment', (e) => {
|
||||||
|
const form = $(e.currentTarget).closest('form');
|
||||||
|
if (form.length > 0 && form.hasClass('comment-form')) {
|
||||||
|
form.addClass('hide');
|
||||||
|
form.parent().find('button.comment-form-reply').show();
|
||||||
|
} else {
|
||||||
|
form.closest('.comment-code-cloud').remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Change status
|
// Change status
|
||||||
const $statusButton = $('#status-button');
|
const $statusButton = $('#status-button');
|
||||||
$('#comment-form textarea').on('keyup', function () {
|
$('#comment-form textarea').on('keyup', function () {
|
||||||
|
@ -1193,6 +1217,7 @@ async function initRepository() {
|
||||||
$mergeButton.parent().show();
|
$mergeButton.parent().show();
|
||||||
$('.instruct-toggle').show();
|
$('.instruct-toggle').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
initReactionSelector();
|
initReactionSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3812,19 +3837,6 @@ function initIssueDue() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.deleteDependencyModal = function (id, type) {
|
|
||||||
$('.remove-dependency')
|
|
||||||
.modal({
|
|
||||||
closable: false,
|
|
||||||
duration: 200,
|
|
||||||
onApprove() {
|
|
||||||
$('#removeDependencyID').val(id);
|
|
||||||
$('#dependencyType').val(type);
|
|
||||||
$('#removeDependencyForm').trigger('submit');
|
|
||||||
}
|
|
||||||
}).modal('show');
|
|
||||||
};
|
|
||||||
|
|
||||||
function initIssueList() {
|
function initIssueList() {
|
||||||
const repolink = $('#repolink').val();
|
const repolink = $('#repolink').val();
|
||||||
const repoId = $('#repoId').val();
|
const repoId = $('#repoId').val();
|
||||||
|
@ -3911,17 +3923,7 @@ $(document).on('submit', '.conversation-holder form', async (e) => {
|
||||||
initClipboard();
|
initClipboard();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.cancelCodeComment = function (btn) {
|
$(document).on('click', '.oauth-login-image', () => {
|
||||||
const form = $(btn).closest('form');
|
|
||||||
if (form.length > 0 && form.hasClass('comment-form')) {
|
|
||||||
form.addClass('hide');
|
|
||||||
form.parent().find('button.comment-form-reply').show();
|
|
||||||
} else {
|
|
||||||
form.closest('.comment-code-cloud').remove();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.onOAuthLoginClick = function () {
|
|
||||||
const oauthLoader = $('#oauth2-login-loader');
|
const oauthLoader = $('#oauth2-login-loader');
|
||||||
const oauthNav = $('#oauth2-login-navigator');
|
const oauthNav = $('#oauth2-login-navigator');
|
||||||
|
|
||||||
|
@ -3934,4 +3936,4 @@ window.onOAuthLoginClick = function () {
|
||||||
oauthLoader.addClass('disabled');
|
oauthLoader.addClass('disabled');
|
||||||
oauthNav.show();
|
oauthNav.show();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
};
|
});
|
||||||
|
|
Loading…
Reference in a new issue