2012-08-22 23:40:09 -04:00
|
|
|
Template.selected_post.events = {
|
|
|
|
'click input[type=submit]': function(){
|
|
|
|
var post = Session.get('selected_post');
|
|
|
|
var $comment = $('#comment');
|
|
|
|
var comment = {
|
|
|
|
post: post._id
|
|
|
|
, body: $comment.val()
|
|
|
|
, submitter: Meteor.user().username
|
|
|
|
, submitted: new Date().getTime()
|
|
|
|
};
|
|
|
|
Comments.insert(comment);
|
|
|
|
$comment.val('');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Template.selected_post.show = function(){
|
2012-08-23 00:15:48 -04:00
|
|
|
return Session.equals('state', 'view_post');
|
2012-08-22 23:40:09 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
Template.selected_post.post = function(){
|
|
|
|
var post = Session.get('selected_post');
|
|
|
|
return post;
|
|
|
|
};
|
2012-08-23 00:35:31 -04:00
|
|
|
|
|
|
|
Template.selected_post.has_comments = function(){
|
|
|
|
var post = Session.get('selected_post');
|
2012-08-23 00:51:31 -04:00
|
|
|
return post.top_level_comments.count() > 0;
|
2012-08-23 00:35:31 -04:00
|
|
|
};
|
|
|
|
|
2012-08-23 00:51:31 -04:00
|
|
|
Template.selected_post.child_comments = function(){
|
2012-08-23 00:35:31 -04:00
|
|
|
var post = Session.get('selected_post');
|
2012-08-23 00:51:31 -04:00
|
|
|
return post.top_level_comments;
|
2012-08-23 00:35:31 -04:00
|
|
|
};
|