MDL-79039 mathjax: Fix variable names

This commit is contained in:
Huong Nguyen
2023-08-25 10:58:30 +07:00
parent 342192561e
commit 15aaa09435
3 changed files with 11 additions and 9 deletions
+1 -1
View File
@@ -6,6 +6,6 @@ define("filter_mathjaxloader/loader",["exports","core_filters/events"],(function
* @copyright 2014 Damyon Wiese <damyon@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
let lang="",configured=!1;_exports.configure=params=>{let script=document.createElement("script");script.type="text/x-mathjax-config",script[window.opera?"innerHTML":"text"]=params.mathjaxconfig,document.getElementsByTagName("head")[0].appendChild(script),lang=params.lang,document.addEventListener(_events.eventTypes.filterContentUpdated,contentUpdated)};const setLocale=()=>{configured||void 0!==window.MathJax&&(window.MathJax.Hub.Queue((function(){window.MathJax.Localization.setLocale(lang)})),window.MathJax.Hub.Configured(),configured=!0)};_exports.typeset=()=>{if(!configured){setLocale();const elements=document.getElementsByClassName("filter_mathjaxloader_equation");for(let i=0;i<elements.length;i++)void 0!==window.MathJax&&window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,elements[i]])}};const contentUpdated=event=>{if(void 0===window.MathJax)return;const processdelay=window.MathJax.Hub.processSectionDelay;window.MathJax.Hub.processSectionDelay=0,window.MathJax.Hub.Config({positionToHash:!1}),setLocale(),event.detail.nodes.forEach((node=>{node.querySelectorAll(".filter_mathjaxloader_equation").forEach((node=>{window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,node])}))})),window.MathJax.Hub.processSectionDelay=processdelay};_exports.contentUpdated=contentUpdated}));
let lang="",configured=!1;_exports.configure=params=>{let script=document.createElement("script");script.type="text/x-mathjax-config",script[window.opera?"innerHTML":"text"]=params.mathjaxconfig,document.getElementsByTagName("head")[0].appendChild(script),lang=params.lang,document.addEventListener(_events.eventTypes.filterContentUpdated,contentUpdated)};const setLocale=()=>{configured||void 0!==window.MathJax&&(window.MathJax.Hub.Queue((function(){window.MathJax.Localization.setLocale(lang)})),window.MathJax.Hub.Configured(),configured=!0)};_exports.typeset=()=>{if(!configured){setLocale();const elements=document.getElementsByClassName("filter_mathjaxloader_equation");elements&&elements.forEach((element=>{void 0!==window.MathJax&&window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,element])}))}};const contentUpdated=event=>{if(void 0===window.MathJax)return;const processDelay=window.MathJax.Hub.processSectionDelay;window.MathJax.Hub.processSectionDelay=0,window.MathJax.Hub.Config({positionToHash:!1}),setLocale(),event.detail.nodes.forEach((node=>{node.getElementsByClassName("filter_mathjaxloader_equation").forEach((node=>{window.MathJax.Hub.Queue(["Typeset",window.MathJax.Hub,node])}))})),window.MathJax.Hub.processSectionDelay=processDelay};_exports.contentUpdated=contentUpdated}));
//# sourceMappingURL=loader.min.js.map
File diff suppressed because one or more lines are too long
+9 -7
View File
@@ -88,10 +88,12 @@ export const typeset = () => {
if (!configured) {
setLocale();
const elements = document.getElementsByClassName('filter_mathjaxloader_equation');
for (let i = 0; i < elements.length; i++) {
if (typeof window.MathJax !== "undefined") {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, elements[i]]);
}
if (elements) {
elements.forEach((element) => {
if (typeof window.MathJax !== "undefined") {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, element]);
}
});
}
}
};
@@ -106,7 +108,7 @@ export const contentUpdated = (event) => {
if (typeof window.MathJax === "undefined") {
return;
}
const processdelay = window.MathJax.Hub.processSectionDelay;
const processDelay = window.MathJax.Hub.processSectionDelay;
// Set the process section delay to 0 when updating the formula.
window.MathJax.Hub.processSectionDelay = 0;
// When content is updated never position to hash, it may cause unexpected document scrolling.
@@ -114,10 +116,10 @@ export const contentUpdated = (event) => {
setLocale();
// The list of HTMLElements in an Array.
event.detail.nodes.forEach((node) => {
const mathjaxElements = node.querySelectorAll('.filter_mathjaxloader_equation');
const mathjaxElements = node.getElementsByClassName('filter_mathjaxloader_equation');
mathjaxElements.forEach((node) => {
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, node]);
});
});
window.MathJax.Hub.processSectionDelay = processdelay;
window.MathJax.Hub.processSectionDelay = processDelay;
};