From a6e5ec942ce9e00e27cfb5415e0332b94edf311f Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Fri, 6 Dec 2013 23:48:11 +0000 Subject: [PATCH] Added LatexView --- .../html/static/notebook/js/widgets/string.js | 23 +++++++++++++++++++ examples/widgets/Part 1 - Basics.ipynb | 1 + 2 files changed, 24 insertions(+) diff --git a/IPython/html/static/notebook/js/widgets/string.js b/IPython/html/static/notebook/js/widgets/string.js index a50915ade..7632f57c4 100644 --- a/IPython/html/static/notebook/js/widgets/string.js +++ b/IPython/html/static/notebook/js/widgets/string.js @@ -36,6 +36,29 @@ define(["notebook/js/widget"], function(widget_manager){ widget_manager.register_widget_view('HTMLView', HTMLView); + + var LatexView = IPython.WidgetView.extend({ + + // Called when view is rendered. + render : function(){ + this.update(); // Set defaults. + }, + + // Handles: Backend -> Frontend Sync + // Frontent -> Frontend Sync + update : function(){ + var that=this; + this.$el.html(this.model.get('value')); + var math_el = that.$el.get(0); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,math_el]); + + return IPython.WidgetView.prototype.update.call(this); + }, + + }); + + widget_manager.register_widget_view('LatexView', LatexView); + var TextAreaView = IPython.WidgetView.extend({ // Called when view is rendered. diff --git a/examples/widgets/Part 1 - Basics.ipynb b/examples/widgets/Part 1 - Basics.ipynb index 0dacb7fbf..307f87360 100644 --- a/examples/widgets/Part 1 - Basics.ipynb +++ b/examples/widgets/Part 1 - Basics.ipynb @@ -314,6 +314,7 @@ "| | *DropdownView* |\n", "| | ListBoxView |\n", "| StringWidget | HTMLView |\n", + "| | LatexView |\n", "| | TextAreaView |\n", "| | *TextBoxView* |\n" ]