2014-07-05 11:24:28 +09:00
|
|
|
Template[getTemplate('comment_edit')].events({
|
2013-10-09 12:39:05 +09:00
|
|
|
'click input[type=submit]': function(e, instance){
|
|
|
|
var comment = this;
|
2014-12-05 08:23:31 +09:00
|
|
|
var content = instance.$('#body').val();
|
2013-10-09 12:39:05 +09:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if(!Meteor.user())
|
2014-11-19 00:00:09 +08:00
|
|
|
throw i18n.t('you_must_be_logged_in');
|
2013-10-09 12:39:05 +09:00
|
|
|
|
|
|
|
Comments.update(comment._id, {
|
|
|
|
$set: {
|
|
|
|
body: content
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-22 10:49:39 +09:00
|
|
|
trackEvent("edit comment", {'postId': comment.postId, 'commentId': comment._id});
|
2014-12-03 00:06:00 -08:00
|
|
|
Router.go('post_page_comment', {_id: comment.postId, commentId: comment._id});
|
2013-10-09 12:39:05 +09:00
|
|
|
},
|
|
|
|
'click .delete-link': function(e){
|
|
|
|
var comment = this;
|
|
|
|
|
|
|
|
e.preventDefault();
|
2014-12-03 00:06:00 -08:00
|
|
|
|
2014-11-19 00:00:09 +08:00
|
|
|
if(confirm(i18n.t("are_you_sure"))){
|
2013-10-09 12:39:05 +09:00
|
|
|
Meteor.call('removeComment', comment._id);
|
2014-12-03 00:06:00 -08:00
|
|
|
Router.go('post_page', {_id: comment.postId});
|
2014-03-20 13:02:07 +05:30
|
|
|
throwError("Your comment has been deleted.");
|
2013-10-09 12:39:05 +09:00
|
|
|
}
|
|
|
|
}
|
2013-11-24 16:13:53 +02:00
|
|
|
});
|