Allow students to delete threads / respones; prepare for edit view for response comments (but not complete)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user