diaspora/app/assets/javascripts/app/views/comment_view.js
2012-04-04 18:59:19 -07:00

32 lines
912 B
JavaScript

//= require ./content_view
app.views.Comment = app.views.Content.extend({
templateName: "comment",
className : "comment media",
events : function() {
return _.extend(app.views.Content.prototype.events, {
"click .comment_delete": "destroyModel"
});
},
presenter : function() {
return _.extend(this.defaultPresenter(), {
canRemove: this.canRemove(),
text : app.helpers.textFormatter(this.model.get("text"), this.model)
})
},
ownComment : function() {
return app.currentUser.authenticated() && this.model.get("author").diaspora_id == app.currentUser.get("diaspora_id")
},
postOwner : function() {
return app.currentUser.authenticated() && this.model.get("parent").author.diaspora_id == app.currentUser.get("diaspora_id")
},
canRemove : function() {
return app.currentUser.authenticated() && (this.ownComment() || this.postOwner())
}
});