Skip to content

Commit

Permalink
MDL-48760 maths filters: Upgrade to mathjax 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Feb 13, 2015
1 parent 7357af2 commit 01dfdf7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 13 deletions.
20 changes: 20 additions & 0 deletions filter/mathjaxloader/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions filter/mathjaxloader/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
$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);

Expand Down
11 changes: 11 additions & 0 deletions filter/mathjaxloader/upgrade.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion filter/mathjaxloader/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
};
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
};
Expand Down
12 changes: 9 additions & 3 deletions filter/mathjaxloader/yui/src/loader/js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}
};

0 comments on commit 01dfdf7

Please sign in to comment.