summaryrefslogtreecommitdiffstats
path: root/client/components/activities/comments.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-06-12 13:59:39 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-06-12 17:48:15 +0200
commitc8945679872a0708eb67a477a99a65d508c84cb0 (patch)
tree5cf9f2cc842f891451f7bc247b5f0833c1ab39e7 /client/components/activities/comments.js
parent216887490e3be0ba141484afc11d37475e91562d (diff)
downloadwekan-c8945679872a0708eb67a477a99a65d508c84cb0.tar.gz
wekan-c8945679872a0708eb67a477a99a65d508c84cb0.tar.bz2
wekan-c8945679872a0708eb67a477a99a65d508c84cb0.zip
Work on the card activities and comments
This commit also introduces a new CSSEvents object that is used to abstract vendor specifics events related to CSS transitions and animations. Fixes #183. Fixes #179.
Diffstat (limited to 'client/components/activities/comments.js')
-rw-r--r--client/components/activities/comments.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/client/components/activities/comments.js b/client/components/activities/comments.js
index e69de29b..d41b86dd 100644
--- a/client/components/activities/comments.js
+++ b/client/components/activities/comments.js
@@ -0,0 +1,49 @@
+var commentFormIsOpen = new ReactiveVar(false);
+
+Template.commentForm.helpers({
+ commentFormIsOpen: function() {
+ return commentFormIsOpen.get();
+ }
+});
+
+Template.commentForm.events({
+ 'click .js-new-comment:not(.focus)': function() {
+ commentFormIsOpen.set(true);
+ },
+ 'submit .js-new-comment-form': function(evt, tpl) {
+ var input = tpl.$('.js-new-comment-input');
+ if ($.trim(input.val())) {
+ CardComments.insert({
+ boardId: this.boardId,
+ cardId: this._id,
+ text: input.val()
+ });
+ input.val('');
+ input.blur();
+ commentFormIsOpen.set(false);
+ Tracker.flush();
+ autosize.update(input);
+ }
+ evt.preventDefault();
+ },
+ // Pressing Ctrl+Enter should submit the form
+ 'keydown form textarea': function(evt, tpl) {
+ if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
+ tpl.find('button[type=submit]').click();
+ }
+ }
+});
+
+Template.commentForm.onDestroyed(function() {
+ commentFormIsOpen.set(false);
+});
+
+EscapeActions.register('inlinedForm',
+ function() {
+ commentFormIsOpen.set(false);
+ $('.js-new-comment-input').blur();
+ },
+ function() { return commentFormIsOpen.get(); }, {
+ noClickEscapeOn: '.js-new-comment'
+ }
+);