12345678910111213141516171819202122232425262728 |
- Template.postItem.helpers({
- ownPost: function () {
- // Template is invoked in the context of a Post, so 'this' is a Post.
- return this.userId === Meteor.userId();
- },
- domain: function () {
- var a = document.createElement('a');
- a.href = this.url;
- return a.hostname;
- },
- upvotedClass: function () {
- var userId = Meteor.userId();
- if (userId && !_.include(this.upvoters, userId)) {
- return "btn-primary upvotable";
- } else {
- return "disabled";
- }
- }
- });
- Template.postItem.events({
- 'click .upvotable': function (e) {
- e.preventDefault();
- Meteor.call('upvote', this._id);
- }
- });
|