Vulcan/client/templates/post.js

34 lines
725 B
JavaScript
Raw Normal View History

2012-08-23 00:15:48 -04:00
Template.post.events = {
2012-08-31 19:08:15 -04:00
'click .discuss-link': function(evt){
evt.preventDefault();
2012-08-30 21:35:48 -04:00
Session.set('selected_post', this);
Session.set('state', 'view_post');
}
, 'click .upvote-link': function(){
Meteor.call('voteForPost', this);
2012-08-23 00:15:48 -04:00
}
};
2012-08-31 19:41:54 -04:00
Template.post.rank = function(){
return 1;
};
2012-08-22 23:40:09 -04:00
Template.post.ago = function(){
var submitted = new Date(this.submitted);
return submitted.toString();
};
2012-08-30 21:35:48 -04:00
Template.post.voted = function(){
var user = Meteor.user();
if(!user) return false;
var myvote = MyVotes.findOne({post: this._id, user: user._id});
return !!myvote;
};
2012-08-31 19:41:54 -04:00
Template.post.domain = function(){
var a = document.createElement('a');
a.href = this.url;
return a.hostname;
};