mirrored from git://git.moodle.org/moodle.git
/
loader.min.js.map
1 lines (1 loc) · 5.71 KB
/
loader.min.js.map
1
{"version":3,"file":"loader.min.js","sources":["../src/loader.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/ //\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Mathjax JS Loader.\n *\n * @module filter_mathjaxloader\n * @copyright 2014 Damyon Wiese <damyon@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {eventTypes} from 'core_filters/events';\n\n/**\n * The users current language - this can't be set until MathJax is loaded - so we need to store it.\n * @property {string} lang\n * @default ''\n * @private\n */\nlet lang = '';\n\n/**\n * Used to prevent configuring MathJax twice.\n * @property {boolean} configured\n * @default false\n * @private\n */\nlet configured = false;\n\n/**\n * Called by the filter when it is active on any page.\n * This does not load MathJAX yet - it addes the configuration to the head incase it gets loaded later.\n * It also subscribes to the filter-content-updated event so MathJax can respond to content loaded by Ajax.\n *\n * @method configure\n * @param {Object} params List of configuration params containing mathjaxconfig (text) and lang\n */\nexport const configure = (params) => {\n // Add a js configuration object to the head.\n // See \"http://docs.mathjax.org/en/latest/dynamic.html#ajax-mathjax\"\n let script = document.createElement(\"script\");\n script.type = \"text/x-mathjax-config\";\n script[(window.opera ? \"innerHTML\" : \"text\")] = params.mathjaxconfig;\n document.getElementsByTagName(\"head\")[0].appendChild(script);\n\n // Save the lang config until MathJax is actually loaded.\n lang = params.lang;\n\n // Listen for events triggered when new text is added to a page that needs\n // processing by a filter.\n document.addEventListener(eventTypes.filterContentUpdated, contentUpdated);\n};\n\n/**\n * Set the correct language for the MathJax menus. Only do this once.\n *\n * @method setLocale\n * @private\n */\nconst setLocale = () => {\n if (!configured) {\n if (typeof window.MathJax !== \"undefined\") {\n window.MathJax.Hub.Queue(function() {\n window.MathJax.Localization.setLocale(lang);\n });\n window.MathJax.Hub.Configured();\n configured = true;\n }\n }\n};\n\n/**\n * Called by the filter when an equation is found while rendering the page.\n *\n * @method typeset\n */\nexport const typeset = () => {\n if (!configured) {\n setLocale();\n const elements = document.getElementsByClassName('filter_mathjaxloader_equation');\n for (let i = 0; i < elements.length; i++) {\n if (typeof window.MathJax !== \"undefined\") {\n window.MathJax.Hub.Queue([\"Typeset\", window.MathJax.Hub, elements[i]]);\n }\n }\n }\n};\n\n/**\n * Handle content updated events - typeset the new content.\n *\n * @method contentUpdated\n * @param {CustomEvent} event - Custom event with \"nodes\" indicating the root of the updated nodes.\n */\nexport const contentUpdated = (event) => {\n if (typeof window.MathJax === \"undefined\") {\n return;\n }\n const processdelay = window.MathJax.Hub.processSectionDelay;\n // Set the process section delay to 0 when updating the formula.\n window.MathJax.Hub.processSectionDelay = 0;\n // When content is updated never position to hash, it may cause unexpected document scrolling.\n window.MathJax.Hub.Config({positionToHash: false});\n setLocale();\n // The list of HTMLElements in an Array.\n event.detail.nodes.forEach((node) => {\n const mathjaxElements = node.querySelectorAll('.filter_mathjaxloader_equation');\n mathjaxElements.forEach((node) => {\n window.MathJax.Hub.Queue([\"Typeset\", window.MathJax.Hub, node]);\n });\n });\n window.MathJax.Hub.processSectionDelay = processdelay;\n};\n"],"names":["lang","configured","params","script","document","createElement","type","window","opera","mathjaxconfig","getElementsByTagName","appendChild","addEventListener","eventTypes","filterContentUpdated","contentUpdated","setLocale","MathJax","Hub","Queue","Localization","Configured","elements","getElementsByClassName","i","length","event","processdelay","processSectionDelay","Config","positionToHash","detail","nodes","forEach","node","querySelectorAll"],"mappings":";;;;;;;;IA6BIA,KAAO,GAQPC,YAAa,qBAUSC,aAGlBC,OAASC,SAASC,cAAc,UACpCF,OAAOG,KAAO,wBACdH,OAAQI,OAAOC,MAAQ,YAAc,QAAWN,OAAOO,cACvDL,SAASM,qBAAqB,QAAQ,GAAGC,YAAYR,QAGrDH,KAAOE,OAAOF,KAIdI,SAASQ,iBAAiBC,mBAAWC,qBAAsBC,uBASzDC,UAAY,KACTf,iBAC6B,IAAnBM,OAAOU,UACdV,OAAOU,QAAQC,IAAIC,OAAM,WACrBZ,OAAOU,QAAQG,aAAaJ,UAAUhB,SAE1CO,OAAOU,QAAQC,IAAIG,aACnBpB,YAAa,qBAUF,SACdA,WAAY,CACbe,kBACMM,SAAWlB,SAASmB,uBAAuB,qCAC5C,IAAIC,EAAI,EAAGA,EAAIF,SAASG,OAAQD,SACH,IAAnBjB,OAAOU,SACdV,OAAOU,QAAQC,IAAIC,MAAM,CAAC,UAAWZ,OAAOU,QAAQC,IAAKI,SAASE,aAYrET,eAAkBW,gBACG,IAAnBnB,OAAOU,qBAGZU,aAAepB,OAAOU,QAAQC,IAAIU,oBAExCrB,OAAOU,QAAQC,IAAIU,oBAAsB,EAEzCrB,OAAOU,QAAQC,IAAIW,OAAO,CAACC,gBAAgB,IAC3Cd,YAEAU,MAAMK,OAAOC,MAAMC,SAASC,OACAA,KAAKC,iBAAiB,kCAC9BF,SAASC,OACrB3B,OAAOU,QAAQC,IAAIC,MAAM,CAAC,UAAWZ,OAAOU,QAAQC,IAAKgB,aAGjE3B,OAAOU,QAAQC,IAAIU,oBAAsBD"}