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();
|
2014-12-09 09:29:17 -08:00
|
|
|
if(!user) return false;
|
2014-07-08 09:06:49 +09:00
|
|
|
return _.include(this.upvoters, user._id);
|
2014-07-05 12:30:56 +09:00
|
|
|
}
|
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()){
|
2014-12-09 09:29:17 -08:00
|
|
|
Router.go('atSignIn');
|
2014-12-06 17:34:08 +09:00
|
|
|
flashMessage(i18n.t("please_log_in_first"), "info");
|
2014-07-07 11:49:21 +09:00
|
|
|
}
|
|
|
|
Meteor.call('upvotePost', post, function(error, result){
|
|
|
|
trackEvent("post upvoted", {'_id': post._id});
|
|
|
|
});
|
|
|
|
}
|
2014-09-08 01:52:09 +08:00
|
|
|
});
|