2012-08-23 00:15:48 -04:00
|
|
|
Template.post.events = {
|
2012-09-04 18:57:07 +09:00
|
|
|
'click input[type=submit]': function(e){
|
|
|
|
e.preventDefault();
|
2012-09-02 23:51:18 +09:00
|
|
|
|
2012-09-05 13:46:57 +09:00
|
|
|
var post = Posts.findOne(Session.get('selected_post_id'));
|
2012-09-04 18:57:07 +09:00
|
|
|
var $comment = $('#comment');
|
|
|
|
Meteor.call('comment', post, null, $comment.val());
|
|
|
|
$comment.val('');
|
2012-09-04 11:14:12 +09:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-09-04 18:57:07 +09:00
|
|
|
Template.post.show = function(){
|
|
|
|
return Session.equals('state', 'view_post');
|
2012-08-23 00:15:48 -04:00
|
|
|
};
|
|
|
|
|
2012-09-04 18:57:07 +09:00
|
|
|
Template.post.show_comment_form = function(){
|
|
|
|
return Meteor.user() !== null;
|
2012-08-31 19:41:54 -04:00
|
|
|
};
|
|
|
|
|
2012-09-04 18:57:07 +09:00
|
|
|
Template.post.post = function(){
|
2012-09-05 11:55:06 +09:00
|
|
|
var post = Posts.findOne(Session.get('selected_post_id'));
|
2012-09-04 18:57:07 +09:00
|
|
|
return post;
|
2012-08-22 23:40:09 -04:00
|
|
|
};
|
2012-08-30 21:35:48 -04:00
|
|
|
|
2012-09-04 18:57:07 +09:00
|
|
|
Template.post.has_comments = function(){
|
2012-09-05 11:55:06 +09:00
|
|
|
var post = Posts.findOne(Session.get('selected_post_id'));
|
|
|
|
if(post){
|
|
|
|
return Comments.find({post: post._id, parent: null}).count() > 0;
|
|
|
|
}
|
2012-08-30 21:35:48 -04:00
|
|
|
};
|
2012-08-31 19:41:54 -04:00
|
|
|
|
2012-09-04 18:57:07 +09:00
|
|
|
Template.post.child_comments = function(){
|
2012-09-05 11:55:06 +09:00
|
|
|
var post = Posts.findOne(Session.get('selected_post_id'));
|
|
|
|
return Comments.find({post: post._id, parent: null});
|
2012-08-31 19:41:54 -04:00
|
|
|
};
|