Get math working.
This commit is contained in:
@@ -20,9 +20,15 @@ class @DiscussionThreadView extends Backbone.View
|
||||
@$(".vote-btn").addClass("is-cast")
|
||||
@$("span.timeago").timeago()
|
||||
Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text)
|
||||
@convertMath()
|
||||
@renderResponses()
|
||||
@
|
||||
|
||||
convertMath: ->
|
||||
element = @$(".post-body")
|
||||
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
|
||||
|
||||
renderResponses: ->
|
||||
$.ajax @model.id, success: (data, textStatus, xhr) =>
|
||||
comments = new Comments(data['content']['children'])
|
||||
@@ -84,7 +90,7 @@ class @DiscussionThreadView extends Backbone.View
|
||||
|
||||
submitComment: ->
|
||||
url = @model.urlFor('reply')
|
||||
body = DiscussionUtil.getWmdContent @$el, $.proxy(@$, @), "reply-body"
|
||||
body = @$("#wmd-input").val()
|
||||
response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 })
|
||||
@renderResponse(response)
|
||||
|
||||
|
||||
@@ -10,9 +10,15 @@ class @ThreadResponseView extends Backbone.View
|
||||
if window.user.voted(@model)
|
||||
@$(".vote-btn").addClass("is-cast")
|
||||
@$(".posted-details").timeago()
|
||||
@convertMath()
|
||||
@renderComments()
|
||||
@
|
||||
|
||||
convertMath: ->
|
||||
element = @$(".response-body")
|
||||
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
|
||||
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
|
||||
|
||||
renderComments: ->
|
||||
@model.get("comments").each @renderComment
|
||||
|
||||
|
||||
@@ -64,56 +64,6 @@
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<article class="new-post-article">
|
||||
<div class="inner-wrapper">
|
||||
<form class="new-post-form">
|
||||
<div class="left-column">
|
||||
<label>Create new post in:</label>
|
||||
<div class="topic-drop">
|
||||
<a href="#" class="topic-drop-btn">Homework / Week 1 <span class="drop-arrow">▾</span></a>
|
||||
<ul class="topic-drop-menu">
|
||||
<li><a href="#">All</a></li>
|
||||
<li><a href="#">Following</a></li>
|
||||
<li><a href="#">General</a></li>
|
||||
<li>
|
||||
<a href="#">Homework</a>
|
||||
<ul>
|
||||
<li><a href="#">Week 1</a></li>
|
||||
<li>
|
||||
<a href="#">Week 2</a>
|
||||
<ul>
|
||||
<li><a href="#">Problem 1</a></li>
|
||||
<li><a href="#">Problem 2</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="options">
|
||||
<input type="checkbox" name="follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
|
||||
<br>
|
||||
<input type="checkbox" name="follow" id="new-post-anonymous" checked><label for="new-post-anonymous">post anonymously</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-column">
|
||||
<div class="form-row">
|
||||
<input type="text" class="new-post-title" name="title" placeholder="Title">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<textarea class="new-post-body" name="body" placeholder="Enter your question or comment…"></textarea>
|
||||
<div class="new-post-preview"><span class="new-post-preview-label">Preview</span></div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<input type="text" class="new-post-tags" name="tags" placeholder="Tags">
|
||||
</div>
|
||||
<input type="submit" class="submit" value="Add post">
|
||||
<a href="#" class="new-post-cancel">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<div class="discussion container">
|
||||
<div class="discussion-body">
|
||||
<div class="sidebar">
|
||||
|
||||
Reference in New Issue
Block a user