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.
This commit is contained in:
Maxime Quandalle 2015-06-12 13:59:39 +02:00
parent 216887490e
commit c894567987
31 changed files with 590 additions and 691 deletions

View file

@ -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'
}
);