MDL-48760 maths filters: Upgrade to mathjax 2.5

This commit is contained in:
Adrian Greeve 2015-02-12 13:21:01 +08:00
parent 7357af2b0c
commit 01dfdf7e41
8 changed files with 62 additions and 13 deletions

View File

@ -47,5 +47,25 @@ function xmldb_filter_mathjaxloader_upgrade($oldversion) {
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.9.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2015021200) {
$httpurl = get_config('filter_mathjaxloader', 'httpurl');
// Don't change the config if it has been manually changed to something besides the default setting value.
if ($httpurl === "http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js") {
set_config('httpurl', 'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js', 'filter_mathjaxloader');
}
$httpsurl = get_config('filter_mathjaxloader', 'httpsurl');
// Don't change the config if it has been manually changed to something besides the default setting value.
if ($httpsurl === "https://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js") {
set_config('httpsurl', 'https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js', 'filter_mathjaxloader');
}
upgrade_plugin_savepoint(true, 2015021200, 'filter', 'mathjaxloader');
}
return true;
}

View File

@ -33,14 +33,14 @@ if ($ADMIN->fulltree) {
$item = new admin_setting_configtext('filter_mathjaxloader/httpurl',
new lang_string('httpurl', 'filter_mathjaxloader'),
new lang_string('httpurl_help', 'filter_mathjaxloader'),
'http://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js',
'http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js',
PARAM_RAW);
$settings->add($item);
$item = new admin_setting_configtext('filter_mathjaxloader/httpsurl',
new lang_string('httpsurl', 'filter_mathjaxloader'),
new lang_string('httpsurl_help', 'filter_mathjaxloader'),
'https://cdn.mathjax.org/mathjax/2.3-latest/MathJax.js',
'https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js',
PARAM_RAW);
$settings->add($item);

View File

@ -1,3 +1,14 @@
=== 2.9 ===
* Update to the latest version of MathJax setting "httpurl" and "httpsurl" to:
http://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js
and
https://cdn.mathjax.org/mathjax/2.5-latest/MathJax.js
=== Before 2.9 ===
Setting "httpsurl" default changed from:
https://c328740.ssl.cf1.rackcdn.com/mathjax/2.3-latest/MathJax.js

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014111000;
$plugin->version = 2015021200;
$plugin->requires = 2014110400; // Requires this Moodle version
$plugin->component= 'filter_mathjaxloader';

View File

@ -113,14 +113,20 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
contentUpdated: function(event) {
var self = this;
Y.use('mathjax', function() {
if (typeof window.MathJax === "undefined") {
return;
}
var processdelay = window.MathJax.Hub.processSectionDelay;
// Set the process section delay to 0 when updating the formula.
window.MathJax.Hub.processSectionDelay = 0;
self._setLocale();
event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) {
if (typeof window.MathJax !== "undefined") {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
}
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
});
});
// Set the delay back to normal after processing.
window.MathJax.Hub.processSectionDelay = processdelay;
});
}
};

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;typeof window.MathJax!="undefined"&&(window.MathJax.Hub.Queue(function(){window.MathJax.Localization.setLocale(e)}),window.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 window.MathJax!="undefined"&&window.MathJax.Hub.Queue(["Typeset",window.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 window.MathJax!="undefined"&&window.MathJax.Hub.Queue(["Typeset",window.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 window.MathJax!="undefined"&&(window.MathJax.Hub.Queue(function(){window.MathJax.Localization.setLocale(e)}),window.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 window.MathJax!="undefined"&&window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,e.getDOMNode()])})})}},contentUpdated:function(t){var n=this;e.use("mathjax",function(){if(typeof window.MathJax=="undefined")return;var e=window.MathJax.Hub.processSectionDelay;window.MathJax.Hub.processSectionDelay=0,n._setLocale(),t.nodes.each(function(e){e.all(".filter_mathjaxloader_equation").each(function(e){window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,e.getDOMNode()])})}),window.MathJax.Hub.processSectionDelay=e})}}},"@VERSION@",{requires:["moodle-core-event"]});

View File

@ -113,14 +113,20 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
contentUpdated: function(event) {
var self = this;
Y.use('mathjax', function() {
if (typeof window.MathJax === "undefined") {
return;
}
var processdelay = window.MathJax.Hub.processSectionDelay;
// Set the process section delay to 0 when updating the formula.
window.MathJax.Hub.processSectionDelay = 0;
self._setLocale();
event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) {
if (typeof window.MathJax !== "undefined") {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
}
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
});
});
// Set the delay back to normal after processing.
window.MathJax.Hub.processSectionDelay = processdelay;
});
}
};

View File

@ -111,14 +111,20 @@ M.filter_mathjaxloader = M.filter_mathjaxloader || {
contentUpdated: function(event) {
var self = this;
Y.use('mathjax', function() {
if (typeof window.MathJax === "undefined") {
return;
}
var processdelay = window.MathJax.Hub.processSectionDelay;
// Set the process section delay to 0 when updating the formula.
window.MathJax.Hub.processSectionDelay = 0;
self._setLocale();
event.nodes.each(function (node) {
node.all('.filter_mathjaxloader_equation').each(function(node) {
if (typeof window.MathJax !== "undefined") {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
}
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node.getDOMNode()]);
});
});
// Set the delay back to normal after processing.
window.MathJax.Hub.processSectionDelay = processdelay;
});
}
};