Vulcan/client/templates/comment_item.js
2012-09-06 11:09:24 +09:00

32 lines
No EOL
876 B
JavaScript

Template.comment_item.events = {
'click .goto-comment': function(event){
event.preventDefault();
var href=event.target.href.replace(/^(?:\/\/|[^\/]+)*\//, "");
Session.set('selected_comment', this);
// Session.set('state', 'reply');
Router.navigate(href, {trigger: true});
}
};
Template.comment_item.ago = function(){
var submitted = new Date(this.submitted);
return submitted.toString();
};
Template.comment_item.child_comments = function(){
var post_id = Session.get('selected_post_id');
var comments = Comments.find({ post: post_id, parent: this._id });
return comments;
};
Template.comment_item.author = function(){
return Meteor.users.findOne(this.user_id).username
};
Template.comment_item.is_my_comment = function(){
if(this.user_id && Meteor.user() && Meteor.user()._id==this.user_id){
return true;
}
return false;
};