Vulcan/client/templates/comment_page.js

51 lines
1.4 KiB
JavaScript
Raw Normal View History

Template.comment_page.events = {
2012-09-05 11:55:06 +09:00
'click input[type=submit]': function(e){
e.preventDefault();
2012-09-08 11:54:08 +09:00
var parentComment_id = Session.get('selected_comment_id');
var post_id=Comments.findOne(parentComment_id).post;
2012-09-05 11:55:06 +09:00
2012-09-08 11:54:08 +09:00
var $comment = $('#comment');
2012-09-08 12:11:26 +09:00
var comment_id= Meteor.call('comment', post_id, parentComment_id, $comment.val());
2012-09-08 11:54:08 +09:00
console.log(comment_id);
2012-09-05 11:55:06 +09:00
Session.set('selected_comment', null);
// Session.set('state', 'view_post');
2012-09-08 12:11:26 +09:00
Router.navigate('posts/'+post_id, {trigger:true});
2012-09-05 11:55:06 +09:00
}
};
Template.comment_page.show = function(){
2012-09-05 11:55:06 +09:00
return Session.equals('state', 'reply');
};
Template.comment_page.show_comment_form = function(){
2012-09-05 11:55:06 +09:00
return Meteor.user() !== null;
};
Template.comment_page.postLoaded = function(){
2012-09-05 11:55:06 +09:00
var selected_comment = Comments.findOne(Session.get('selected_comment_id'));
if(selected_comment){
return true;
}else{
return false;
}
}
Template.comment_page.post = function(){
2012-09-05 11:55:06 +09:00
var selected_comment = Comments.findOne(Session.get('selected_comment_id'));
2012-09-08 11:54:08 +09:00
console.log(selected_comment);
2012-09-05 11:55:06 +09:00
if(selected_comment){
var post = selected_comment.post;
return Posts.findOne(post);
}
};
Template.comment_page.comment = function(){
2012-09-08 11:54:08 +09:00
var comment = Comments.findOne(Session.get('selected_comment_id'));
Template.comment_page.repress_recursion = true;
2012-09-05 11:55:06 +09:00
return comment;
};
2012-09-10 20:29:17 +09:00
Session.set('StyleNewRecords', new Date());