mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
27 lines
923 B
JavaScript
27 lines
923 B
JavaScript
![]() |
Template[getTemplate('userUpvotedPosts')].created = function () {
|
||
|
Session.set('upvotedPostsShown', 5);
|
||
|
};
|
||
|
|
||
|
Template[getTemplate('userUpvotedPosts')].helpers({
|
||
|
upvotedPosts: function () {
|
||
|
// extend upvotes with each upvoted post
|
||
|
if(!!this.votes.upvotedPosts){
|
||
|
var extendedVotes = this.votes.upvotedPosts.map(function (item) {
|
||
|
var post = Posts.findOne(item.itemId);
|
||
|
return _.extend(item, post);
|
||
|
});
|
||
|
return _.first(extendedVotes, Session.get('upvotedPostsShown'));
|
||
|
}
|
||
|
},
|
||
|
hasMoreUpvotedPosts: function () {
|
||
|
return !!this.votes.upvotedPosts && this.votes.upvotedPosts.length > Session.get('upvotedPostsShown');
|
||
|
}
|
||
|
});
|
||
|
|
||
|
Template[getTemplate('userUpvotedPosts')].events({
|
||
|
'click .upvotedposts-more': function (e) {
|
||
|
e.preventDefault();
|
||
|
var upvotedPostsShown = Session.get('upvotedPostsShown');
|
||
|
Session.set('upvotedPostsShown', upvotedPostsShown + 10);
|
||
|
}
|
||
|
});
|