moving, checking MathJax typesetting to WidgetView

widget rendering should not fail hard if MathJax is not available
This commit is contained in:
Nicholas Bollweg (Nick) 2014-11-15 09:01:35 -05:00
parent 7e3c583f27
commit 9cd878cf0f
6 changed files with 23 additions and 13 deletions

View File

@ -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
]);
}
});

View File

@ -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();
}
}

View File

@ -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');

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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();
}
}