From 09112f42487e4c2d098236a52a6c73228ba500e0 2014-01-16 10:57:07 From: Jonathan Frederic Date: 2014-01-16 10:57:07 Subject: [PATCH] Added LatexView --- diff --git a/IPython/html/static/notebook/js/widgets/string.js b/IPython/html/static/notebook/js/widgets/string.js index a50915a..7632f57 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 0dacb7f..307f873 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" ]