MDL-46748 MathJax filter: Make misconfigured mathjax url less "fatal" for Atto.

This commit is contained in:
Damyon Wiese 2014-08-11 11:37:35 +08:00
parent 14cb870f46
commit fa268b7ed6
4 changed files with 40 additions and 22 deletions

View File

@ -76,11 +76,13 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
_setLocale: function() { _setLocale: function() {
if (!this._configured) { if (!this._configured) {
var lang = this._lang; var lang = this._lang;
MathJax.Hub.Queue(function () { if (typeof MathJax !== "undefined") {
MathJax.Localization.setLocale(lang); MathJax.Hub.Queue(function () {
}); MathJax.Localization.setLocale(lang);
MathJax.Hub.Configured(); });
this._configured = true; MathJax.Hub.Configured();
this._configured = true;
}
} }
}, },
@ -95,7 +97,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
Y.use('mathjax', function() { Y.use('mathjax', function() {
self._setLocale(); self._setLocale();
Y.all('.filter_mathjaxloader_equation').each(function(node) { Y.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
} }
@ -112,7 +116,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
self._setLocale(); self._setLocale();
event.nodes.each(function (node) { event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) { node.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
}); });

View File

@ -1 +1 @@
YUI.add("moodle-filter_mathjaxloader-loader",function(e,t){M.filter_mathjaxloader=M.filter_mathjaxloader||{_lang:"",_configured:!1,configure:function(t){var n=document.createElement("script");n.type="text/x-mathjax-config",n[window.opera?"innerHTML":"text"]=t.mathjaxconfig,document.getElementsByTagName("head")[0].appendChild(n),this._lang=t.lang,e.on(M.core.event.FILTER_CONTENT_UPDATED,this.contentUpdated,this)},_setLocale:function(){if(!this._configured){var e=this._lang;MathJax.Hub.Queue(function(){MathJax.Localization.setLocale(e)}),MathJax.Hub.Configured(),this._configured=!0}},typeset:function(){if(!this._configured){var t=this;e.use("mathjax",function(){t._setLocale(),e.all(".filter_mathjaxloader_equation").each(function(e){MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.getDOMNode()])})})}},contentUpdated:function(t){var n=this;e.use("mathjax",function(){n._setLocale(),t.nodes.each(function(e){e.all(".filter_mathjaxloader_equation").each(function(e){MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.getDOMNode()])})})})}}},"@VERSION@",{requires:["moodle-core-event"]}); YUI.add("moodle-filter_mathjaxloader-loader",function(e,t){M.filter_mathjaxloader=M.filter_mathjaxloader||{_lang:"",_configured:!1,configure:function(t){var n=document.createElement("script");n.type="text/x-mathjax-config",n[window.opera?"innerHTML":"text"]=t.mathjaxconfig,document.getElementsByTagName("head")[0].appendChild(n),this._lang=t.lang,e.on(M.core.event.FILTER_CONTENT_UPDATED,this.contentUpdated,this)},_setLocale:function(){if(!this._configured){var e=this._lang;typeof MathJax!="undefined"&&(MathJax.Hub.Queue(function(){MathJax.Localization.setLocale(e)}),MathJax.Hub.Configured(),this._configured=!0)}},typeset:function(){if(!this._configured){var t=this;e.use("mathjax",function(){t._setLocale(),e.all(".filter_mathjaxloader_equation").each(function(e){typeof MathJax!="undefined"&&MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.getDOMNode()])})})}},contentUpdated:function(t){var n=this;e.use("mathjax",function(){n._setLocale(),t.nodes.each(function(e){e.all(".filter_mathjaxloader_equation").each(function(e){typeof MathJax!="undefined"&&MathJax.Hub.Queue(["Typeset",MathJax.Hub,e.getDOMNode()])})})})}}},"@VERSION@",{requires:["moodle-core-event"]});

View File

@ -76,11 +76,13 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
_setLocale: function() { _setLocale: function() {
if (!this._configured) { if (!this._configured) {
var lang = this._lang; var lang = this._lang;
MathJax.Hub.Queue(function () { if (typeof MathJax !== "undefined") {
MathJax.Localization.setLocale(lang); MathJax.Hub.Queue(function () {
}); MathJax.Localization.setLocale(lang);
MathJax.Hub.Configured(); });
this._configured = true; MathJax.Hub.Configured();
this._configured = true;
}
} }
}, },
@ -95,7 +97,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
Y.use('mathjax', function() { Y.use('mathjax', function() {
self._setLocale(); self._setLocale();
Y.all('.filter_mathjaxloader_equation').each(function(node) { Y.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
} }
@ -112,7 +116,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
self._setLocale(); self._setLocale();
event.nodes.each(function (node) { event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) { node.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
}); });

View File

@ -74,11 +74,13 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
_setLocale: function() { _setLocale: function() {
if (!this._configured) { if (!this._configured) {
var lang = this._lang; var lang = this._lang;
MathJax.Hub.Queue(function () { if (typeof MathJax !== "undefined") {
MathJax.Localization.setLocale(lang); MathJax.Hub.Queue(function () {
}); MathJax.Localization.setLocale(lang);
MathJax.Hub.Configured(); });
this._configured = true; MathJax.Hub.Configured();
this._configured = true;
}
} }
}, },
@ -93,7 +95,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
Y.use('mathjax', function() { Y.use('mathjax', function() {
self._setLocale(); self._setLocale();
Y.all('.filter_mathjaxloader_equation').each(function(node) { Y.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
} }
@ -110,7 +114,9 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
self._setLocale(); self._setLocale();
event.nodes.each(function (node) { event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) { node.all('.filter_mathjaxloader_equation').each(function(node) {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]); if (typeof MathJax !== "undefined") {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, node.getDOMNode()]);
}
}); });
}); });
}); });