Commit 2900c169 by Carlos Andrés Rocha

Load inline comments templates at render time and not during page load

parent f4ba65c5
......@@ -4,8 +4,6 @@ class @DiscussionThreadEditView extends Backbone.View
"click .post-update": "update"
"click .post-cancel": "cancel_edit"
template: _.template($("#thread-edit-template").html())
$: (selector) ->
@$el.find(selector)
......@@ -13,6 +11,7 @@ class @DiscussionThreadEditView extends Backbone.View
super()
render: ->
@template = _.template($("#thread-edit-template").html())
@$el.html(@template(@model.toJSON()))
@delegateEvents()
DiscussionUtil.makeWmdEditor @$el, $.proxy(@$, @), "edit-post-body"
......
......@@ -11,8 +11,6 @@ if Backbone?
"click .expand-post": "expandPost"
"click .collapse-post": "collapsePost"
template: -> DiscussionUtil.getTemplate("_inline_thread")
initLocal: ->
@$local = @$el.children(".discussion-article").children(".local")
@$delegateElement = @$local
......@@ -22,12 +20,14 @@ if Backbone?
@model.on "change", @updateModelDetails
render: ->
@template = DiscussionUtil.getTemplate("_inline_thread")
if not @model.has('abbreviatedBody')
@abbreviateBody()
params = $.extend(@model.toJSON(),{expanded: @expanded})
if not @model.get('anonymous')
params = $.extend(params, user:{username: @model.username, user_url: @model.user_url})
@$el.html(Mustache.render(@template(), params))
@$el.html(Mustache.render(@template, params))
@initLocal()
@delegateEvents()
@renderDogear()
......
......@@ -7,8 +7,6 @@ class @DiscussionThreadShowView extends DiscussionContentView
"click .action-delete": "delete"
"click .action-openclose": "toggleClosed"
template: _.template($("#thread-show-template").html())
$: (selector) ->
@$el.find(selector)
......@@ -17,6 +15,7 @@ class @DiscussionThreadShowView extends DiscussionContentView
@model.on "change", @updateModelDetails
render: ->
@template = _.template($("#thread-show-template").html())
@$el.html(@template(@model.toJSON()))
@delegateEvents()
@renderDogear()
......
......@@ -4,8 +4,6 @@ if Backbone?
events:
"click .discussion-submit-post": "submitComment"
template: _.template($("#thread-template").html())
$: (selector) ->
@$el.find(selector)
......@@ -14,6 +12,7 @@ if Backbone?
@createShowView()
render: ->
@template = _.template($("#thread-template").html())
@$el.html(@template(@model.toJSON()))
@delegateEvents()
......
if Backbone?
class @ResponseCommentView extends DiscussionContentView
tagName: "li"
template: _.template($("#response-comment-template").html())
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
render: ->
@template = _.template($("#response-comment-template").html())
params = @model.toJSON()
params['deep'] = @options.deep
if @options.deep
......@@ -20,6 +21,7 @@ if Backbone?
@$el.find(".timeago").timeago()
@convertMath()
@
convertMath: ->
body = @$el.find(".response-body")
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.html()
......
......@@ -4,7 +4,6 @@ if Backbone?
console.log('test 2')
class @ThreadResponseView extends DiscussionContentView
tagName: "li"
template: _.template($("#thread-response-template").html())
events:
"click .vote-btn": "toggleVote"
......@@ -13,6 +12,7 @@ if Backbone?
"click .action-delete": "delete"
render: ->
@template = _.template($("#thread-response-template").html())
@$el.html(@template(@model.toJSON()))
@initLocal()
@delegateEvents()
......
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