2014-07-05 12:30:56 +09:00
|
|
|
Template[getTemplate('postUpvote')].helpers({
|
2014-07-08 09:06:49 +09:00
|
|
|
upvoted: function(){
|
|
|
|
var user = Meteor.user();
|
|
|
|
if(!user) return false;
|
|
|
|
return _.include(this.upvoters, user._id);
|
|
|
|
},
|
2014-07-05 12:30:56 +09:00
|
|
|
oneBasedRank: function(){
|
|
|
|
if(typeof this.rank !== 'undefined')
|
|
|
|
return this.rank + 1;
|
|
|
|
}
|
2014-07-07 11:49:21 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
Template[getTemplate('postUpvote')].events({
|
|
|
|
'click .upvote-link': function(e, instance){
|
|
|
|
var post = this;
|
|
|
|
e.preventDefault();
|
|
|
|
if(!Meteor.user()){
|
|
|
|
Router.go('/signin');
|
|
|
|
throwError(i18n.t("Please log in first"));
|
|
|
|
}
|
|
|
|
Meteor.call('upvotePost', post, function(error, result){
|
|
|
|
trackEvent("post upvoted", {'_id': post._id});
|
|
|
|
});
|
|
|
|
}
|
2014-07-05 12:30:56 +09:00
|
|
|
});
|