moving the js to a seperated file in web_src/js/features/

Signed-off-by: Alex Lau(AvengerMoJo) <avengermojo@gmail.com>
This commit is contained in:
Alex Lau(AvengerMoJo) 2024-04-22 13:40:37 +08:00
parent 32cb52662f
commit c4b923886c
No known key found for this signature in database
GPG Key ID: E924333A268354EA
3 changed files with 23 additions and 0 deletions

View File

@ -124,6 +124,7 @@
{{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}}
</form>
</div>
<!--
<script>
window.addEventListener('DOMContentLoaded', function() {
var checkboxes = document.querySelectorAll('.ui.radio.checkbox');
@ -143,3 +144,4 @@
});
});
</script>
-->

View File

@ -0,0 +1,19 @@
export function initRequireActionsSelect() {
const raselect = document.getElementById('add-require-actions-modal');
if (!raselect) return;
const checkboxes = document.querySelectorAll('.ui.radio.checkbox');
checkboxes.forEach(function(checkbox) {
checkbox.addEventListener('change', function() {
var hiddenInput = this.nextElementSibling;
var isChecked = this.querySelector('input[type="radio"]').checked;
hiddenInput.disabled = !isChecked;
// Disable other hidden inputs
checkboxes.forEach(function(otherCheckbox) {
var otherHiddenInput = otherCheckbox.nextElementSibling;
if (otherCheckbox !== checkbox) {
otherHiddenInput.disabled = isChecked;
}
});
});
});
}

View File

@ -54,6 +54,7 @@ import {initRepoCodeView} from './features/repo-code.js';
import {initSshKeyFormParser} from './features/sshkey-helper.js';
import {initUserSettings} from './features/user-settings.js';
import {initRepoArchiveLinks} from './features/repo-common.js';
import {initRequireActionsSelect} from './features/require-actions-select.js';
import {initRepoMigrationStatusChecker} from './features/repo-migrate.js';
import {
initRepoSettingGitHook,
@ -143,6 +144,7 @@ onDomReady(() => {
initRepoActivityTopAuthorsChart();
initRepoArchiveLinks();
initRequireActionsSelect();
initRepoBranchButton();
initRepoCodeView();
initRepoCommentForm();