Add @references for deeply nested (3+) comments.
This commit is contained in:
@@ -8,7 +8,12 @@ if Backbone?
|
||||
@$delegateElement = @$local
|
||||
|
||||
render: ->
|
||||
@$el.html(@template(@model.toJSON()))
|
||||
params = @model.toJSON()
|
||||
params['deep'] = @options.deep
|
||||
if @options.deep
|
||||
params['parent_id'] = @options.parent.id
|
||||
params['parent_username'] = @options.parent.get('username')
|
||||
@$el.html(@template(params))
|
||||
@initLocal()
|
||||
@delegateEvents()
|
||||
@renderAttrs()
|
||||
|
||||
@@ -27,15 +27,15 @@ if Backbone?
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
|
||||
|
||||
renderComments: ->
|
||||
@model.get("comments").each @renderComment
|
||||
@model.get("comments").each (comment) => @renderComment(comment, false, null)
|
||||
|
||||
renderComment: (comment) =>
|
||||
renderComment: (comment, deep=false, parent=null) =>
|
||||
comment.set('thread', @model.get('thread'))
|
||||
view = new ResponseCommentView(model: comment)
|
||||
view = new ResponseCommentView(model: comment, deep: deep, parent: parent)
|
||||
view.render()
|
||||
@$el.find(".comments li:last").before(view.el)
|
||||
children = new Comments(comment.get('children'))
|
||||
children.each @renderComment
|
||||
children.each (child) => @renderComment child, true, comment
|
||||
|
||||
|
||||
toggleVote: (event) ->
|
||||
|
||||
@@ -95,7 +95,13 @@
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="response-comment-template">
|
||||
<p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">–posted <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p>
|
||||
<p id="comment_${'<%- id %>'}">
|
||||
${'<% if (deep) {%>'}
|
||||
<a href="#comment_${'<%- parent_id %>'}">@${'<%- parent_username %>'}</a>:
|
||||
${'<% }%>'}
|
||||
<span class="response-body">${'<%- body %>'}</span>
|
||||
<span class="posted-details">–posted <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span>
|
||||
</p>
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="thread-list-item-template">
|
||||
|
||||
Reference in New Issue
Block a user