mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
moving, checking MathJax typesetting to WidgetView
widget rendering should not fail hard if MathJax is not available
This commit is contained in:
parent
7e3c583f27
commit
9cd878cf0f
@ -389,6 +389,17 @@ define(["widgets/js/manager",
|
||||
this.on('displayed', callback, context);
|
||||
}
|
||||
},
|
||||
|
||||
typeset: function(element){
|
||||
// check if MathJax is available, and if so use it to
|
||||
// typeset some DOM
|
||||
if(!window.MathJax){ return; }
|
||||
return MathJax.Hub.Queue([
|
||||
"Typeset",
|
||||
MathJax.Hub,
|
||||
element
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ define([
|
||||
this.$title.html(" "); // Preserve title height
|
||||
} else {
|
||||
this.$title.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$title.get(0)]);
|
||||
this.typeset(this.$title.get(0));
|
||||
}
|
||||
|
||||
var button_text = this.model.get('button_text');
|
||||
|
@ -156,7 +156,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
|
||||
@ -324,7 +324,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
@ -444,7 +444,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
return ProgressView.__super__.update.apply(this);
|
||||
|
@ -98,7 +98,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
@ -231,7 +231,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
@ -346,7 +346,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
@ -469,7 +469,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ define([
|
||||
* changed by another view or by a state update from the back-end.
|
||||
*/
|
||||
this.$el.text(this.model.get('value'));
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$el.get(0)]);
|
||||
|
||||
this.typeset(this.$el.get(0));
|
||||
return LatexView.__super__.update.apply(this);
|
||||
},
|
||||
});
|
||||
@ -117,7 +116,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
@ -201,7 +200,7 @@ define([
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.text(description);
|
||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$label.get(0)]);
|
||||
this.typeset(this.$label.get(0));
|
||||
this.$label.show();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user