define('home/views/ProfilePostView', [ 'underscore', 'handlebars', 'home/views/PostView', 'home/templates/profileCardPost', ], function (_, Handlebars, PostView, profileCardPostTemplate ) { 'use strict'; var ProfilePostView = PostView.extend({ template: profileCardPostTemplate, events: { 'click [data-action=request-spam-review]': 'requestSpamReview', }, ui: { spamActions: '[data-role=spam-actions]', }, initialize: function (options) { options = options || { }; options.shouldCollapse = false; PostView.prototype.initialize.apply(this, arguments); this.replyAuthor = options.replyAuthor; this.bindToAuthor(); }, bindToAuthor: function () { if (!this.model.author) { this.listenToOnce(this.model, 'changeRelated:author', this.bindToAuthor); return; } this.listenTo(this.model.author, 'change:flaggedForSpamReview', this.renderSpamAlert); }, renderSpamAlert: function () { var data = this.serializeData(); data = this.mixinTemplateHelpers(data); this.ui.spamActions.html(Handlebars.partials.spamActions(data)); }, templateHelpers: function () { var helpers = PostView.prototype.templateHelpers.apply(this, arguments); helpers = _.defaults({ isAuthor: this.model.author.isSessionUser(), authorPendingSpamReview: this.model.author.get('flaggedForSpamReview'), replyAuthor: this.replyAuthor && this.replyAuthor.toJSON(), }, helpers); return helpers; }, requestSpamReview: function () { this.model.author.requestSpamReview(); }, }); return ProfilePostView; });