Commit 9f59a9a8 by Matthew Mongeau

Get math working.

parent 7f0f7195
...@@ -20,9 +20,15 @@ class @DiscussionThreadView extends Backbone.View ...@@ -20,9 +20,15 @@ class @DiscussionThreadView extends Backbone.View
@$(".vote-btn").addClass("is-cast") @$(".vote-btn").addClass("is-cast")
@$("span.timeago").timeago() @$("span.timeago").timeago()
Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text) Markdown.makeWmdEditor @$(".reply-body"), "", DiscussionUtil.urlFor("upload"), (text) -> DiscussionUtil.postMathJaxProcessor(text)
@convertMath()
@renderResponses() @renderResponses()
@ @
convertMath: ->
element = @$(".post-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
renderResponses: -> renderResponses: ->
$.ajax @model.id, success: (data, textStatus, xhr) => $.ajax @model.id, success: (data, textStatus, xhr) =>
comments = new Comments(data['content']['children']) comments = new Comments(data['content']['children'])
...@@ -84,7 +90,7 @@ class @DiscussionThreadView extends Backbone.View ...@@ -84,7 +90,7 @@ class @DiscussionThreadView extends Backbone.View
submitComment: -> submitComment: ->
url = @model.urlFor('reply') 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 }) response = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 })
@renderResponse(response) @renderResponse(response)
......
...@@ -10,9 +10,15 @@ class @ThreadResponseView extends Backbone.View ...@@ -10,9 +10,15 @@ class @ThreadResponseView extends Backbone.View
if window.user.voted(@model) if window.user.voted(@model)
@$(".vote-btn").addClass("is-cast") @$(".vote-btn").addClass("is-cast")
@$(".posted-details").timeago() @$(".posted-details").timeago()
@convertMath()
@renderComments() @renderComments()
@ @
convertMath: ->
element = @$(".response-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")]
renderComments: -> renderComments: ->
@model.get("comments").each @renderComment @model.get("comments").each @renderComment
......
...@@ -64,56 +64,6 @@ ...@@ -64,56 +64,6 @@
</div> </div>
</nav> </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 container">
<div class="discussion-body"> <div class="discussion-body">
<div class="sidebar"> <div class="sidebar">
......
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