mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
31 lines
1 KiB
JavaScript
31 lines
1 KiB
JavaScript
Template.comment_form.rendered = function(){
|
|
if(Meteor.user() && !this.editor){
|
|
this.editor = new EpicEditor(EpicEditorOptions).load();
|
|
}
|
|
}
|
|
|
|
Template.comment_form.events = {
|
|
'click input[type=submit]': function(e, instance){
|
|
e.preventDefault();
|
|
var $comment = $('#comment');
|
|
var content = instance.editor.exportFile();
|
|
|
|
if(selectedCommentId=Session.get('selectedCommentId')){
|
|
// post a child comment
|
|
var parentCommentId =selectedCommentId;
|
|
var postId=Comments.findOne(parentCommentId).post;
|
|
var commentId=Meteor.call('comment', postId, parentCommentId, content);
|
|
Session.set('selectedCommentId', null);
|
|
Router.navigate('posts/'+postId, {trigger:true});
|
|
}else{
|
|
// post a root comment
|
|
var parentCommentId=null;
|
|
var postId=Session.get('selectedPostId');
|
|
var commentId=Meteor.call('comment', postId, parentCommentId, content);
|
|
instance.editor.importFile('editor', '');
|
|
}
|
|
|
|
trackEvent("new comment", {'postId': postId, 'commentId': commentId});
|
|
|
|
}
|
|
};
|