mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 20:16:39 -04:00
36 lines
1.4 KiB
JavaScript
36 lines
1.4 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();
|
|
$(e.target).addClass('disabled');
|
|
var $comment = $('#comment');
|
|
var content = instance.editor.exportFile();
|
|
|
|
if(window.template=='comment_page'){
|
|
// post a child comment
|
|
var selectedCommentId=Session.get('selectedCommentId')
|
|
var parentCommentId =selectedCommentId;
|
|
var postId=Comments.findOne(parentCommentId).post;
|
|
Meteor.call('comment', postId, parentCommentId, content, function(error, result){
|
|
Session.set('selectedCommentId', null);
|
|
trackEvent("new child comment", {'postId': postId, 'commentId': result, 'parentId': parentCommentId});
|
|
Session.set('scrollToCommentId', result);
|
|
Router.navigate('posts/'+postId, {trigger:true});
|
|
});
|
|
}else{
|
|
// post a root comment
|
|
var parentCommentId=null;
|
|
var postId=Session.get('selectedPostId');
|
|
Meteor.call('comment', postId, parentCommentId, content, function(error, result){
|
|
trackEvent("new root comment", {'postId': postId, 'commentId': result});
|
|
Session.set('scrollToCommentId', result);
|
|
instance.editor.importFile('editor', '');
|
|
});
|
|
}
|
|
}
|
|
};
|