Add JavaScript to make placeholder text update along with word count
This commit is contained in:
parent
16d9dfef4c
commit
d46e1e7397
3 changed files with 25 additions and 10 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
= f.input :event_type_id, as: :select,
|
||||
collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id,
|
||||
data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]},
|
||||
data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]},
|
||||
include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' }
|
||||
|
||||
- if @program.languages.present?
|
||||
|
|
@ -46,17 +46,19 @@
|
|||
250
|
||||
words.
|
||||
|
||||
= f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } },
|
||||
hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)')
|
||||
%br
|
||||
|
||||
= f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' },
|
||||
hint: markdown_hint('Only conference organizers will read this.')
|
||||
|
||||
%p
|
||||
You have used
|
||||
%span#abstract-count #{@event.submission_word_count}
|
||||
%span#submission-count #{@event.submission_word_count}
|
||||
words. Submission descriptions must be between
|
||||
%span#abstract-minimum-word-count
|
||||
%span#submission-minimum-word-count
|
||||
0
|
||||
and
|
||||
%span#abstract-maximum-word-count
|
||||
%span#submission-maximum-word-count
|
||||
250
|
||||
words.
|
||||
|
||||
|
|
|
|||
|
|
@ -66,12 +66,12 @@
|
|||
|
||||
%p
|
||||
You have used
|
||||
%span#abstract-count #{@event.submission_word_count}
|
||||
%span#submission-count #{@event.submission_word_count}
|
||||
words. Submission descriptions must be between
|
||||
%span#abstract-minimum-word-count
|
||||
%span#submission-minimum-word-count
|
||||
0
|
||||
and
|
||||
%span#abstract-maximum-word-count
|
||||
%span#submission-maximum-word-count
|
||||
250
|
||||
words.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue