Move word counting javascript to the page
It really does not need to run on every page load...
This commit is contained in:
parent
c63ed43825
commit
30bc21c96a
3 changed files with 26 additions and 24 deletions
|
|
@ -90,3 +90,27 @@
|
|||
- submit_copy = action_is_edit ? 'Update Proposal' : 'Create Proposal'
|
||||
= f.submit submit_copy, class: 'btn btn-success'
|
||||
|
||||
- content_for :script_head do
|
||||
:javascript
|
||||
/* 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);
|
||||
} );
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue