Handle default eula checkbox

This commit is contained in:
Marcus Moore 2023-07-11 16:36:03 -07:00
parent af681d8190
commit 44d8b2fd5e
No known key found for this signature in database

View file

@ -114,24 +114,31 @@
@section('moar_scripts')
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function () {
let textarea = $('textarea[name="eula_text"]');
let useDefaultEula = $('input[name="use_default_eula"]');
let shouldSendEmail = $('input[name="checkin_email"]')
let message = $('#email_will_be_sent_message');
function handleEulaChange() {
if (textarea.val().trim() !== '') {
if (textarea.val().trim() !== '' || useDefaultEula.is(":checked")) {
shouldSendEmail.prop('checked', true);
shouldSendEmail.prop('disabled', true);
message.show();
textarea.prop('disabled', useDefaultEula.is(":checked"));
} else {
shouldSendEmail.prop('checked', false);
shouldSendEmail.prop('disabled', false);
message.hide();
textarea.prop('disabled', useDefaultEula.is(":checked"));
}
}
textarea.on('change keyup', function() {
textarea.on('change keyup', function () {
handleEulaChange();
});
useDefaultEula.change(function () {
handleEulaChange();
});