Resize description/notes textareas as we type

This commit is contained in:
2016-11-04 15:27:02 +01:00
parent 54c1d89866
commit 5ec5c5bb04
2 changed files with 13 additions and 21 deletions

View File

@@ -132,15 +132,13 @@ script.
$('.js-help').openModalUrl('Help', "{{ url_for('attract.help', project_url=project.url) }}");
/* Resize textareas */
var textAreaFields = $('#item-description, #item-notes');
{% if 'PUT' in shot.allowed_methods %}
/* Resize textareas */
var textAreaFields = $('#item-description, #item-notes');
textAreaFields.each(function(){
var descriptionText = $(this).val(),
matches = descriptionText.match(/\n/g),
breaks = matches ? matches.length : 2;
if (descriptionText){
$(this).attr('rows', breaks + 2);
}
});
textAreaFields.each(function(){
$(this)
.autoResize()
.blur();
});
{% endif %}

View File

@@ -47,7 +47,7 @@
| {% if 'PUT' in task.allowed_methods %}
.input-group
textarea#task-description(
textarea#item-description(
name="description",
type="text",
rows=1,
@@ -160,15 +160,9 @@ script.
loadComments("{{ url_for('nodes.comments_for_node', node_id=task['_id']) }}");
{% if 'PUT' in task.allowed_methods %}
/* Resize textarea */
var descriptionField = $('#task-description');
var descriptionText = descriptionField.val(),
matches = descriptionText.match(/\n/g),
breaks = matches ? matches.length : 2;
if (descriptionText){
descriptionField.attr('rows',breaks + 4);
}
$('#item-description')
.autoResize()
.blur();
{% endif %}
$('.js-help').openModalUrl('Help', "{{ url_for('attract.help', project_url=project.url) }}");