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