mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
25 lines
670 B
JavaScript
25 lines
670 B
JavaScript
Template[getTemplate('postUpvote')].helpers({
|
|
upvoted: function(){
|
|
var user = Meteor.user();
|
|
if(!user) return false;
|
|
return _.include(this.upvoters, user._id);
|
|
},
|
|
oneBasedRank: function(){
|
|
if(typeof this.rank !== 'undefined')
|
|
return this.rank + 1;
|
|
}
|
|
});
|
|
|
|
Template[getTemplate('postUpvote')].events({
|
|
'click .upvote-link': function(e, instance){
|
|
var post = this;
|
|
e.preventDefault();
|
|
if(!Meteor.user()){
|
|
Router.go('atSignIn');
|
|
flashMessage(i18n.t("please_log_in_first"), "info");
|
|
}
|
|
Meteor.call('upvotePost', post, function(error, result){
|
|
trackEvent("post upvoted", {'_id': post._id});
|
|
});
|
|
}
|
|
});
|