Vulcan/client/views/posts/posts_list.js
2014-07-18 09:18:52 +09:00

24 lines
No EOL
866 B
JavaScript

Template[getTemplate('posts_list')].helpers({
post_item: function () {
return getTemplate('post_item');
},
posts : function () {
if(this.postsList){ // XXX
this.postsList.rewind();
var posts = this.postsList.map(function (post, index, cursor) {
post.rank = index;
return post;
});
return posts;
}
},
hasMorePosts: function(){
// as long as we ask for N posts and all N posts showed up, then keep showing the "load more" button
return parseInt(Session.get('postsLimit')) == this.postsCount
},
loadMoreUrl: function () {
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
var categorySegment = Session.get('categorySlug') ? Session.get('categorySlug') + '/' : '';
return '/' + Session.get('view') + '/' + categorySegment + count;
}
});