Skip to content

Commit

Permalink
Add autosize to comments input
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Oct 4, 2016
1 parent c5d24a6 commit 5ca50d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion apps/comments/css/comments.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#commentsTabView .newCommentForm .submit {
position: absolute;
top: 1px;
bottom: 1px;
right: 8px;
width: 30px;
margin: 0;
Expand All @@ -47,6 +47,10 @@
margin-right: 6px;
}

#commentsTabView .newCommentForm textarea {
resize: none;
}

#commentsTabView .comment {
position: relative;
z-index: 1;
Expand Down
8 changes: 6 additions & 2 deletions apps/comments/js/commentstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'{{/if}}' +
' </div>' +
' <form class="newCommentForm">' +
' <input type="text" class="message" placeholder="{{newMessagePlaceholder}}" value="{{message}}" />' +
' <textarea rows="1" class="message" placeholder="{{newMessagePlaceholder}}">{{message}}</textarea>' +
' <input class="submit icon-confirm" type="submit" value="" />' +
'{{#if isEditMode}}' +
' <input class="cancel pull-right" type="button" value="{{cancelText}}" />' +
Expand Down Expand Up @@ -174,6 +174,8 @@
}
this.delegateEvents();
this.$el.find('.message').on('keydown input change', this._onTypeComment);

autosize(this.$el.find('.newCommentRow textarea'))
},

_formatItem: function(commentModel) {
Expand Down Expand Up @@ -281,6 +283,9 @@
$formRow.find('.avatar').replaceWith($comment.find('.avatar').clone());
$formRow.find('.has-tooltip').tooltip();

// Enable autosize
autosize($formRow.find('textarea'));

return false;
},

Expand Down Expand Up @@ -346,7 +351,6 @@
}
});


return false;
},

Expand Down

0 comments on commit 5ca50d9

Please sign in to comment.