Move word counting javascript to the page

It really does not need to run on every page load...
This commit is contained in:
Henne Vogelsang 2024-03-05 15:32:14 +01:00
parent c63ed43825
commit 30bc21c96a
No known key found for this signature in database
GPG key ID: 97DDB66BDAF8D4D6
3 changed files with 26 additions and 24 deletions

View file

@ -142,29 +142,6 @@ 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 */
function updateEventTypeRequirements() {
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);
$("#abstract-minimum-word-count").text(min);
word_count($('#event_abstract').get(0), 'abstract-count', max);
}
$("#event_event_type_id").change(updateEventTypeRequirements);
updateEventTypeRequirements();
/* Count the proposal abstract length */
$("#event_abstract").on('input', function() {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'abstract-count', max);
} );
});
/* Commodity function for modal windows */
window.build_dialog = function(selector, content) {