From 33a0a3cc8775caa85b905f6346f1d12905ff3f98 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Mon, 2 Jun 2014 16:02:18 -0700 Subject: [PATCH] Add latex support in widget labels, This PR even adds support to use latex in PopupWidget titles. --- IPython/html/static/widgets/js/widget_bool.js | 1 + IPython/html/static/widgets/js/widget_container.js | 1 + IPython/html/static/widgets/js/widget_int.js | 5 ++++- IPython/html/static/widgets/js/widget_selection.js | 4 ++++ IPython/html/static/widgets/js/widget_string.js | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/IPython/html/static/widgets/js/widget_bool.js b/IPython/html/static/widgets/js/widget_bool.js index 2f4669ce8..5bf8626c9 100644 --- a/IPython/html/static/widgets/js/widget_bool.js +++ b/IPython/html/static/widgets/js/widget_bool.js @@ -60,6 +60,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } diff --git a/IPython/html/static/widgets/js/widget_container.js b/IPython/html/static/widgets/js/widget_container.js index 6fcbaca84..c6e21f9e0 100644 --- a/IPython/html/static/widgets/js/widget_container.js +++ b/IPython/html/static/widgets/js/widget_container.js @@ -240,6 +240,7 @@ define(["widgets/js/widget"], function(WidgetManager) { this.$title.html(" "); // Preserve title height } else { this.$title.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$title.get(0)]); } var button_text = this.model.get('button_text'); diff --git a/IPython/html/static/widgets/js/widget_int.js b/IPython/html/static/widgets/js/widget_int.js index c70477b89..f6761abb7 100644 --- a/IPython/html/static/widgets/js/widget_int.js +++ b/IPython/html/static/widgets/js/widget_int.js @@ -32,7 +32,7 @@ define(["widgets/js/widget"], function(WidgetManager){ // Put the slider in a container this.$slider_container = $('
') .addClass('widget-hslider') - .append(this.$slider) + .append(this.$slider); this.$el_to_style = this.$slider_container; // Set default element to style this.$el.append(this.$slider_container); @@ -113,6 +113,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } @@ -192,6 +193,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } @@ -294,6 +296,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } return ProgressView.__super__.update.apply(this); diff --git a/IPython/html/static/widgets/js/widget_selection.js b/IPython/html/static/widgets/js/widget_selection.js index d6d4f046b..f95622e49 100644 --- a/IPython/html/static/widgets/js/widget_selection.js +++ b/IPython/html/static/widgets/js/widget_selection.js @@ -96,6 +96,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } @@ -187,6 +188,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } @@ -279,6 +281,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } @@ -362,6 +365,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } diff --git a/IPython/html/static/widgets/js/widget_string.js b/IPython/html/static/widgets/js/widget_string.js index 4fe80d4ef..9a979427d 100644 --- a/IPython/html/static/widgets/js/widget_string.js +++ b/IPython/html/static/widgets/js/widget_string.js @@ -113,6 +113,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } } @@ -185,6 +186,7 @@ define(["widgets/js/widget"], function(WidgetManager){ this.$label.hide(); } else { this.$label.text(description); + MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]); this.$label.show(); } }