Rev 1 | AutorÃa | Comparar con el anterior | Ultima modificación | Ver Log |
define("filter_mathjaxloader/loader",["exports","core_filters/events"],(function(_exports,_events){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.typeset=_exports.loadMathJax=_exports.contentUpdated=_exports.configure=void 0;/*** Mathjax JS Loader.** @module filter_mathjaxloader/loader* @copyright 2014 Damyon Wiese <damyon@moodle.com>* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later*/let mathJaxUrl=null,mathJaxLoaded=null;_exports.configure=params=>{let config={};try{""!==params.mathjaxconfig&&(config=JSON.parse(params.mathjaxconfig))}catch(e){window.console.error("Invalid JSON in mathjaxconfig.",e)}"object"!=typeof config&&(config={}),"object"!=typeof config.loader&&(config.loader={}),Array.isArray(config.loader.load)||(config.loader.load=[]),"object"!=typeof config.startup&&(config.startup={}),config.loader.load.includes("ui/safe")||config.loader.load.push("ui/safe"),config.startup.typeset=!1,config.locale=params.lang,mathJaxUrl=params.mathjaxurl,window.MathJax=config,document.addEventListener(_events.eventTypes.filterContentUpdated,contentUpdated)};const typesetNode=node=>{node instanceof HTMLElement&&loadMathJax().then((()=>{window.MathJax.startup.promise=window.MathJax.startup.promise.then((()=>window.MathJax.typesetPromise([node]))).then((()=>{(0,_events.notifyFilterContentRenderingComplete)([node])})).catch((e=>{window.console.log(e)}))}))};_exports.typeset=()=>{const elements=document.getElementsByClassName("filter_mathjaxloader_equation");for(const element of elements)typesetNode(element)};const contentUpdated=event=>{let listOfElementContainMathJax=[],hasMathJax=!1;event.detail.nodes.forEach((node=>{if(!(node instanceof HTMLElement))return;const mathjaxElements=node.querySelectorAll(".filter_mathjaxloader_equation");mathjaxElements.length>0&&(hasMathJax=!0),listOfElementContainMathJax.push(mathjaxElements)})),hasMathJax&&listOfElementContainMathJax.forEach((mathjaxElements=>{mathjaxElements.forEach((node=>typesetNode(node)))}))};_exports.contentUpdated=contentUpdated;const loadMathJax=()=>{if(!mathJaxLoaded){if(!mathJaxUrl)return Promise.reject(new Error("URL to MathJax not set."));mathJaxLoaded=new Promise(((resolve,reject)=>{const script=document.createElement("script");script.type="text/javascript",script.onload=resolve,script.onerror=reject,script.src=mathJaxUrl,document.getElementsByTagName("head")[0].appendChild(script)}))}return mathJaxLoaded};_exports.loadMathJax=loadMathJax}));//# sourceMappingURL=loader.min.js.map