From a3faaf0c18cf4b5c61bf745b237d8e7bdfbd20ef Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 17 Jul 2014 13:23:43 +0100 Subject: [PATCH] Add in mathjax directive --- .../web/app/views/project/editor/chat.jade | 5 +++- .../coffee/ide/chat/directives/mathjax.coffee | 24 +++++++++++++++++++ .../web/public/coffee/ide/chat/index.coffee | 1 + .../ide/chat/services/chatMessages.coffee | 1 + 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 services/web/public/coffee/ide/chat/directives/mathjax.coffee diff --git a/services/web/app/views/project/editor/chat.jade b/services/web/app/views/project/editor/chat.jade index 06ecc8058d..82be09921f 100644 --- a/services/web/app/views/project/editor/chat.jade +++ b/services/web/app/views/project/editor/chat.jade @@ -33,7 +33,10 @@ aside.chat( }" ) .arrow(ng-style="{'border-color': 'hsl({{ hue(message.user) }}, 60%, 80%)'}") - p(ng-repeat="content in message.contents track by $index") {{ content }} + p( + mathjax, + ng-repeat="content in message.contents track by $index" + ) {{ content }} .new-message textarea( diff --git a/services/web/public/coffee/ide/chat/directives/mathjax.coffee b/services/web/public/coffee/ide/chat/directives/mathjax.coffee new file mode 100644 index 0000000000..c2c211717a --- /dev/null +++ b/services/web/public/coffee/ide/chat/directives/mathjax.coffee @@ -0,0 +1,24 @@ +define [ + "base" + "mathjax" +], (App) -> + mathjaxConfig = + "HTML-CSS": { availableFonts: ["TeX"] }, + TeX: + equationNumbers: { autoNumber: "AMS" }, + useLabelIDs: false + tex2jax: + inlineMath: [ ['$','$'], ["\\(","\\)"] ], + displayMath: [ ['$$','$$'], ["\\[","\\]"] ], + processEscapes: true + + + MathJax.Hub.Config(mathjaxConfig); + + App.directive "mathjax", () -> + return { + link: (scope, element, attrs) -> + setTimeout () -> + MathJax.Hub.Queue(["Typeset", MathJax.Hub, element.get(0)]) + , 0 + } \ No newline at end of file diff --git a/services/web/public/coffee/ide/chat/index.coffee b/services/web/public/coffee/ide/chat/index.coffee index f60b41d1fb..d5a537903b 100644 --- a/services/web/public/coffee/ide/chat/index.coffee +++ b/services/web/public/coffee/ide/chat/index.coffee @@ -2,4 +2,5 @@ define [ "ide/chat/controllers/ChatButtonController" "ide/chat/controllers/ChatController" "ide/chat/controllers/ChatMessageController" + "ide/chat/directives/mathjax" ], () -> \ No newline at end of file diff --git a/services/web/public/coffee/ide/chat/services/chatMessages.coffee b/services/web/public/coffee/ide/chat/services/chatMessages.coffee index b7c3c75dcd..dbe19aba1a 100644 --- a/services/web/public/coffee/ide/chat/services/chatMessages.coffee +++ b/services/web/public/coffee/ide/chat/services/chatMessages.coffee @@ -76,6 +76,7 @@ define [ prependMessage(message) appendMessage = (message) -> + console.log "MESSAGES", message, chat.state.messages chat.state.newMessage = message lastMessage = chat.state.messages[chat.state.messages.length - 1]