reversing order of arguments, as text may already exist

This commit is contained in:
Nicholas Bollweg (Nick) 2014-11-15 10:32:43 -05:00
parent 00fc31b0a8
commit 57f05c4a2b
6 changed files with 21 additions and 17 deletions

View File

@ -390,11 +390,15 @@ define(["widgets/js/manager",
}
},
typeset: function(text, $el){
// check if MathJax is available, and if so use it to
// typeset some jQuery selection
$el.text(text);
if(!window.MathJax){ return; }
typeset: function($el, text){
// after (optionally) updating a selection's text, check if
// MathJax is available and typeset it
if(arguments.length > 1){
$el.text(text);
}
if(!window.MathJax){
return;
}
return MathJax.Hub.Queue(["Typeset", MathJax.Hub, $el.get(0)]);
}
});

View File

@ -62,7 +62,7 @@ define([
if (description.trim().length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}

View File

@ -319,7 +319,7 @@ define([
if (description.trim().length === 0) {
this.$title.html(" "); // Preserve title height
} else {
this.typeset(description, this.$title);
this.typeset(this.$title, description);
}
var button_text = this.model.get('button_text');

View File

@ -155,7 +155,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
@ -322,7 +322,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}
@ -441,7 +441,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
return ProgressView.__super__.update.apply(this);

View File

@ -97,7 +97,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}
@ -230,7 +230,7 @@ define([
this.$label.hide();
} else {
this.$label.text(description);
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}
@ -345,7 +345,7 @@ define([
this.$label.hide();
} else {
this.$label.text();
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}
@ -467,7 +467,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}

View File

@ -43,7 +43,7 @@ define([
* Called when the model is changed. The model may have been
* changed by another view or by a state update from the back-end.
*/
this.typeset(this.model.get('value'), this.$el);
this.typeset(this.$el, this.model.get('value'));
return LatexView.__super__.update.apply(this);
},
});
@ -114,7 +114,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}
@ -197,7 +197,7 @@ define([
if (description.length === 0) {
this.$label.hide();
} else {
this.typeset(description, this.$label);
this.typeset(this.$label, description);
this.$label.show();
}
}