Vulcan/client/views/posts/modules/post_content.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-07-05 11:24:28 +09:00
Template[getTemplate('postContent')].helpers({
postHeading: function () {
return postHeading;
},
postMeta: function () {
return postMeta;
2014-07-04 14:07:50 +09:00
},
getTemplate: function () {
return getTemplate(this.template);
},
2014-07-04 14:07:50 +09:00
sourceLink: function(){
return !!this.url ? this.url : "/posts/"+this._id;
},
current_domain: function(){
return "http://"+document.domain;
},
timestamp: function(){
time = this.status == STATUS_APPROVED ? this.postedAt : this.createdAt;
return moment(time).format("MMMM Do, h:mm:ss a");
},
userAvatar: function(){
// THIS FUNCTION IS DEPRECATED -- package bengott:avatar is used instead.
2014-07-04 14:07:50 +09:00
var author = Meteor.users.findOne(this.userId, {reactive: false});
if(!!author)
return getAvatarUrl(author); // ALSO DEPRECATED
2014-07-04 14:07:50 +09:00
},
inactiveClass: function(){
return (isAdmin(Meteor.user()) && this.inactive) ? i18n.t('inactive') : "";
},
commentsDisplayText: function(){
return this.comments == 1 ? i18n.t('comment') : i18n.t('comments');
}
2014-07-07 11:49:21 +09:00
});
Template[getTemplate('postContent')].events({
'click .approve-link': function(e, instance){
Meteor.call('approvePost', this);
e.preventDefault();
},
'click .unapprove-link': function(e, instance){
Meteor.call('unapprovePost', this);
e.preventDefault();
}
2014-07-04 14:07:50 +09:00
});