Allow students to delete threads / respones; prepare for edit view for response comments (but not complete)

This commit is contained in:
Arjun Singh
2012-09-13 21:58:59 -07:00
parent 3cbc075f7b
commit 6b8e2c78ab
3 changed files with 25 additions and 30 deletions

View File

@@ -2,35 +2,30 @@ if Backbone?
class @ResponseCommentView extends DiscussionContentView
tagName: "li"
initLocal: ->
# TODO .response-local is the parent of the comments so @$local is null, not sure what was intended here...
@$local = @$el.find(".response-local")
@$delegateElement = @$local
$: (selector) ->
@$el.find(selector)
initialize: ->
super()
@createShowView()
render: ->
@template = _.template($("#response-comment-template").html())
params = @model.toJSON()
params['deep'] = @model.hasOwnProperty('parent')
if @model.hasOwnProperty('parent')
params['parent_id'] = @model.parent.id
params['parent_username'] = @model.parent.get('username')
@$el.html(@template(params))
@initLocal()
@delegateEvents()
@renderAttrs()
@markAsStaff()
@$el.find(".timeago").timeago()
@convertMath()
@renderShowView()
@
convertMath: ->
body = @$el.find(".response-body")
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.html()
# This removes paragraphs so that comments are more compact
body.children("p").each (index, elem) ->
$(elem).replaceWith($(elem).html())
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
createShowView: () ->
markAsStaff: ->
if DiscussionUtil.isStaff(@model.get("user_id"))
@$el.find("a.profile-link").after('<span class="staff-label">staff</span>')
if @editView?
@editView.undelegateEvents()
@editView.$el.empty()
@editView = null
@showView = new ResponseCommentShowView(model: @model)
renderSubView: (view) ->
view.setElement(@$el)
view.render()
view.delegateEvents()
renderShowView: () ->
@renderSubView(@showView)