Fill submission text if the field is currently empty

This commit is contained in:
CactusPuppy 2021-03-04 23:43:27 -08:00
parent e4fea7188b
commit 1f9da86e39
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82

View file

@ -147,6 +147,15 @@ function word_count(text, divId, maxcount) {
});
};
function fill_if_empty(text_area, filler) {
let area = $('#' + text_area);
if (!area.val()) {
area.val(filler);
area.trigger('change');
}
}
/* Wait for the DOM to be ready before attaching events to the elements */
$( document ).ready(function() {
/* Set the minimum and maximum proposal abstract and submission text word length */
@ -155,15 +164,15 @@ $( document ).ready(function() {
var max = $selected.data("max-words");
var min = $selected.data("min-words");
// Set the placeholder text for the abstract
fill_if_empty('event_submission_text', $selected.data("help"));
$("#abstract-maximum-word-count").text(max);
$("#submission-maximum-word-count").text(max);
$("#abstract-minimum-word-count").text(min);
$("#submission-minimum-word-count").text(min);
word_count($('#event_abstract').get(0), 'abstract-count', max);
word_count($('#event_submission_text').get(0), 'submission-count', max);
// Set the placeholder text for the abstract
$('#event_submission_text').attr("placeholder", $selected.data("help"));
})
.trigger('change');