Vulcan/client/views/posts/modules/post_upvote.js

26 lines
665 B
JavaScript
Raw Normal View History

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(getSigninUrl());
throwError(i18n.t("please_log_in_first"));
2014-07-07 11:49:21 +09:00
}
Meteor.call('upvotePost', post, function(error, result){
trackEvent("post upvoted", {'_id': post._id});
});
}
});