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

View File

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