Your IP : 216.73.216.95


Current Path : /var/www/ljmtc/cbt/lib/amd/build/
Upload File :
Current File : /var/www/ljmtc/cbt/lib/amd/build/prefetch.min.js.map

{"version":3,"sources":["../src/prefetch.js"],"names":["initialPrefetchComplete","templateList","stringList","prefetchTimer","fetchQueue","templatesToLoad","slice","then","Templates","prefetchTemplates","catch","mappedStringsToFetch","stringsToFetch","Object","keys","forEach","component","push","map","key","Str","get_strings","processQueue","setTimeout","Config","iconsystemmodule","IconSystem","iconSystem","prefetchTemplate","getTemplateName","init","templatesNames","concat","templateName","prefetchStrings","prefetchString"],"mappings":"+IAwBA,uD,+1BAGIA,CAAAA,CAAuB,G,CAGvBC,CAAY,CAAG,E,CAGfC,CAAU,CAAG,E,CAEbC,C,CAOEC,CAAU,CAAG,UAAM,CAErB,GAAIH,CAAJ,CAAkB,CACd,GAAMI,CAAAA,CAAe,CAAGJ,CAAY,CAACK,KAAb,EAAxB,CACAL,CAAY,CAAG,EAAf,CACA,mSAAO,gBAAP,0CACCM,IADD,CACM,SAAAC,CAAS,QAAIA,CAAAA,CAAS,CAACC,iBAAV,CAA4BJ,CAA5B,CAAJ,CADf,EAECK,KAFD,EAGH,CAGD,GAAMC,CAAAA,CAAoB,CAAGT,CAA7B,CACAA,CAAU,CAAG,EAAb,CAEA,GAAMU,CAAAA,CAAc,CAAG,EAAvB,CACAC,MAAM,CAACC,IAAP,CAAYH,CAAZ,EAAkCI,OAAlC,CAA0C,SAAAC,CAAS,CAAI,CACnDJ,CAAc,CAACK,IAAf,OAAAL,CAAc,GAASD,CAAoB,CAACK,CAAD,CAApB,CAAgCE,GAAhC,CAAoC,SAAAC,CAAG,CAAI,CAC9D,MAAO,CAACH,SAAS,CAATA,CAAD,CAAYG,GAAG,CAAHA,CAAZ,CACV,CAFsB,CAAT,EAGjB,CAJD,EAOI,6RAAO,UAAP,oCACCZ,IADD,CACM,SAAAa,CAAG,QAAIA,CAAAA,CAAG,CAACC,WAAJ,CAAgBT,CAAhB,CAAJ,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CAACc,CAAD,CAAV,CAAwB,EAC3B,CAEDd,CAAU,CAACc,CAAD,CAAV,CAAsBC,IAAtB,CAA2BE,CAA3B,EAEAG,CAAY,EACf,C,CAGDb,CAAiB,CAAC,GAAGuB,MAAH,CACd,CAAC,cAAD,CADc,CAEd,CAAC,YAAD,CAFc,CAGd,CAAC,qBAAD,CAHc,CAAD,CAAjB,CAOAE,CAAe,CAAC,MAAD,CAAS,CACpB,QADoB,CAEpB,kBAFoB,CAGpB,SAHoB,CAIpB,aAJoB,CAAT,CAAf,CAMAA,CAAe,CAAC,WAAD,CAAc,CACzB,UADyB,CAEzB,UAFyB,CAAd,CAAf,C,UAKe,CACXN,gBAAgB,CAAhBA,CADW,CAEXnB,iBAAiB,CAAjBA,CAFW,CAGX0B,cAAc,CAAdA,CAHW,CAIXD,eAAe,CAAfA,CAJW,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\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 * Prefetch module to help lazily load content for use on the current page.\n *\n * @module     core/prefetch\n * @class      prefetch\n * @package    core\n * @copyright  2020 Andrew Nicols <andrew@nicols.co.uk>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport Config from 'core/config';\n\n// Keep track of whether the initial prefetch has occurred.\nlet initialPrefetchComplete = false;\n\n// Prefetch templates.\nlet templateList = [];\n\n// Prefetch strings.\nlet stringList = {};\n\nlet prefetchTimer;\n\n/**\n * Fetch all queued items in the queue.\n *\n * Should only be called via processQueue.\n */\nconst fetchQueue = () => {\n    // Prefetch templates.\n    if (templateList) {\n        const templatesToLoad = templateList.slice();\n        templateList = [];\n        import('core/templates')\n        .then(Templates => Templates.prefetchTemplates(templatesToLoad))\n        .catch();\n    }\n\n    // Prefetch strings.\n    const mappedStringsToFetch = stringList;\n    stringList = {};\n\n    const stringsToFetch = [];\n    Object.keys(mappedStringsToFetch).forEach(component => {\n        stringsToFetch.push(...mappedStringsToFetch[component].map(key => {\n            return {component, key};\n        }));\n    });\n\n    if (stringsToFetch) {\n        import('core/str')\n        .then(Str => Str.get_strings(stringsToFetch))\n        .catch();\n    }\n};\n\n/**\n * Process the prefetch queues as required.\n *\n * The initial call will queue the first fetch after a delay.\n * Subsequent fetches are immediate.\n */\nconst processQueue = () => {\n    if (prefetchTimer) {\n        // There is a live prefetch timer. The initial prefetch has been scheduled but is not complete.\n        return;\n    }\n\n    // The initial prefetch has compelted. Just queue as normal.\n    if (initialPrefetchComplete) {\n        fetchQueue();\n\n        return;\n    }\n\n    // Queue the initial prefetch in a short while.\n    prefetchTimer = setTimeout(() => {\n        initialPrefetchComplete = true;\n        prefetchTimer = null;\n\n        // Ensure that the icon system is loaded.\n        // This can be quite slow and delay UI interactions if it is loaded on demand.\n        import(Config.iconsystemmodule)\n        .then(IconSystem => {\n            const iconSystem = new IconSystem();\n            prefetchTemplate(iconSystem.getTemplateName());\n\n            return iconSystem;\n        })\n        .then(iconSystem => {\n            fetchQueue();\n            iconSystem.init();\n\n            return;\n        })\n        .catch();\n    }, 500);\n};\n\n/**\n * Add a set of templates to the prefetch queue.\n *\n * @param {Array} templatesNames\n */\nconst prefetchTemplates = templatesNames => {\n    templateList = templateList.concat(templatesNames);\n\n    processQueue();\n};\n\n/**\n * Add a single template to the prefetch queue.\n *\n * @param {String} templateName\n * @returns {undefined}\n */\nconst prefetchTemplate = templateName => prefetchTemplates([templateName]);\n\n/**\n * Add a set of strings from the same component to the prefetch queue.\n *\n * @param {String} component\n * @param {String[]} keys\n */\nconst prefetchStrings = (component, keys) => {\n    if (!stringList[component]) {\n        stringList[component] = [];\n    }\n\n    stringList[component] = stringList[component].concat(keys);\n\n    processQueue();\n};\n\n/**\n * Add a single string to the prefetch queue.\n *\n * @param {String} component\n * @param {String} key\n */\nconst prefetchString = (component, key) => {\n    if (!stringList[component]) {\n        stringList[component] = [];\n    }\n\n    stringList[component].push(key);\n\n    processQueue();\n};\n\n// Prefetch some commonly-used templates.\nprefetchTemplates([].concat(\n    ['core/loading'],\n    ['core/modal'],\n    ['core/modal_backdrop'],\n));\n\n// And some commonly used strings.\nprefetchStrings('core', [\n    'cancel',\n    'closebuttontitle',\n    'loading',\n    'savechanges',\n]);\nprefetchStrings('core_form', [\n    'showless',\n    'showmore',\n]);\n\nexport default {\n    prefetchTemplate,\n    prefetchTemplates,\n    prefetchString,\n    prefetchStrings,\n};\n"],"file":"prefetch.min.js"}