Only make textarea larger if there's text

This commit is contained in:
2016-11-01 16:16:20 +01:00
parent aa2f97c7c9
commit 491b26e5eb

View File

@@ -44,6 +44,7 @@
textarea#task-description.input-transparent(
name="description",
type="text",
rows=1,
placeholder='Description') {{ task.description | hide_none }}
.input-group-flex
@@ -155,11 +156,16 @@ script.
{% if 'PUT' in task.allowed_methods %}
/* Resize textarea */
var text = $('#task-description').val(),
matches = text.match(/\n/g),
var descriptionField = $('#task-description');
var descriptionText = descriptionField.val(),
matches = descriptionText.match(/\n/g),
breaks = matches ? matches.length : 2;
$('#task-description').attr('rows',breaks + 4);
console.log(matches);
if (descriptionText){
descriptionField.attr('rows',breaks + 4);
}
{% endif %}
$('.js-help').openModalUrl('Help', "{{ url_for('attract.help', project_url=project.url) }}");