Add JavaScript to make placeholder text update along with word count

This commit is contained in:
CactusPuppy 2021-02-18 23:27:20 -08:00
parent 16d9dfef4c
commit d46e1e7397
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
3 changed files with 25 additions and 10 deletions

View file

@ -149,15 +149,21 @@ function word_count(text, divId, maxcount) {
/* Wait for the DOM to be ready before attaching events to the elements */
$( document ).ready(function() {
/* Set the minimum and maximum proposal abstract word length */
/* Set the minimum and maximum proposal abstract and submission text word length */
$("#event_event_type_id").change(function () {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
var min = $selected.data("min-words");
$("#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');
@ -167,6 +173,13 @@ $( document ).ready(function() {
var max = $selected.data("max-words");
word_count(this, 'abstract-count', max);
} );
/* Count the submission text length */
$("#event_submission_text").bind('change keyup paste input', function() {
var $selected = $("event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'submission-count', max);
});
});
/* Commodity function for modal windows */