Commit 2d105265 by Ibrahim Awwal

Add @references for deeply nested (3+) comments.

parent fc459f7e
...@@ -8,7 +8,12 @@ if Backbone? ...@@ -8,7 +8,12 @@ if Backbone?
@$delegateElement = @$local @$delegateElement = @$local
render: -> 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() @initLocal()
@delegateEvents() @delegateEvents()
@renderAttrs() @renderAttrs()
......
...@@ -27,15 +27,15 @@ if Backbone? ...@@ -27,15 +27,15 @@ if Backbone?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]] MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
renderComments: -> 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')) comment.set('thread', @model.get('thread'))
view = new ResponseCommentView(model: comment) view = new ResponseCommentView(model: comment, deep: deep, parent: parent)
view.render() view.render()
@$el.find(".comments li:last").before(view.el) @$el.find(".comments li:last").before(view.el)
children = new Comments(comment.get('children')) children = new Comments(comment.get('children'))
children.each @renderComment children.each (child) => @renderComment child, true, comment
toggleVote: (event) -> toggleVote: (event) ->
......
...@@ -95,7 +95,13 @@ ...@@ -95,7 +95,13 @@
</script> </script>
<script type="text/template" id="response-comment-template"> <script type="text/template" id="response-comment-template">
<p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">&ndash;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">&ndash;posted <span class="timeago" title="${'<%- created_at %>'}">${'<%- created_at %>'}</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span>
</p>
</script> </script>
<script type="text/template" id="thread-list-item-template"> <script type="text/template" id="thread-list-item-template">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment