Skip to content

Commit

Permalink
Reformat JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaxy102 committed Feb 14, 2022
1 parent d678b08 commit f28c7c0
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/main/resources/static/js/toolkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,22 @@ function setInvisible(el) {
}

function triggerComponentSelect(element) {
$('#componentSelectBase').children(':not(#componentSelectType)').each(function () {setInvisible(this);setNonReqiured(this);unsetName(this)});
$('#componentSelectBase').children(':not(#componentSelectType)').each(function () {
setInvisible(this);
setNonReqiured(this);
unsetName(this)
});
const targetElementIdQuery = '#componentSelect-' + (element.value === '' ? 'NONE' : element.value);
$(targetElementIdQuery).each(function () {setVisible(this);setReqiured(this);setName(this, 'component')});
$(targetElementIdQuery).each(function () {
setVisible(this);
setReqiured(this);
setName(this, 'component')
});
}

// Inspired by https://thecoderain.blogspot.com/2020/11/generate-valid-random-email-js-jquery.html
const emailChars = '1234567890';

function generateEmailAddress(btnEl) {
const target = $(btnEl).parent().children().first().children().first();
var mail = 'mail';
Expand All @@ -106,9 +115,15 @@ $(document).ready(function () {
$("#contentFrame").bind('load', highlightActiveSubapp);
$("#contentFrame").bind('load', highlightFlowStep);
// Alert on pending changes
$('input').change(() => {hasChanges = true;});
$('select').change(() => {hasChanges = true;});
$('form').submit(() => {hasChanges = false;});
$('input').change(() => {
hasChanges = true;
});
$('select').change(() => {
hasChanges = true;
});
$('form').submit(() => {
hasChanges = false;
});
window.onbeforeunload = (ev) => {
if (hasChanges) ev.returnValue = "Changes you made may not be saved.";
}
Expand All @@ -129,7 +144,8 @@ $(document).ready(function () {
});
$('.button-spinner').click(function () {
if (this.form.checkValidity()) addSpinner($(this));
})
});
// Toasts
$('.toast').each(function () {
(new bootstrap.Toast(this, {})).show();
})
Expand Down

0 comments on commit f28c7c0

Please sign in to comment.