From 1acb6185dec1570673c43db33e82fb94360ef620 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Thu, 30 Aug 2012 13:06:37 -0400 Subject: [PATCH] Get math working. --- .../views/discussion_thread_view.coffee | 8 ++- .../views/thread_response_view.coffee | 6 +++ lms/templates/discussion/single_thread.html | 50 ------------------- 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee index 9301c3ecd4..021fa63d74 100644 --- a/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee +++ b/lms/static/coffee/src/discussion/views/discussion_thread_view.coffee @@ -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) diff --git a/lms/static/coffee/src/discussion/views/thread_response_view.coffee b/lms/static/coffee/src/discussion/views/thread_response_view.coffee index be651bc3f3..dbe6a13111 100644 --- a/lms/static/coffee/src/discussion/views/thread_response_view.coffee +++ b/lms/static/coffee/src/discussion/views/thread_response_view.coffee @@ -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 diff --git a/lms/templates/discussion/single_thread.html b/lms/templates/discussion/single_thread.html index aa67fabcb3..d70bbbc4f5 100644 --- a/lms/templates/discussion/single_thread.html +++ b/lms/templates/discussion/single_thread.html @@ -64,56 +64,6 @@ -
-
-
-
- - -
- -
- -
-
-
-
- -
-
- -
Preview
-
-
- -
- - Cancel -
-
-
-
-