diff --git a/lib/amd/build/prefetch.min.js b/lib/amd/build/prefetch.min.js index 94652dc48f7..95f70ab1cf8 100644 --- a/lib/amd/build/prefetch.min.js +++ b/lib/amd/build/prefetch.min.js @@ -1,2 +1,2 @@ -define ("core/prefetch",["exports","core/config"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var i="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function c(a){return g(a)||f(a)||e(a)||d()}function d(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(a,b){if(!a)return;if("string"==typeof a)return h(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return h(a,b)}function f(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}function g(a){if(Array.isArray(a))return h(a)}function h(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c=b.default.jsrev){return}if(m){return}if(j){n();return}m=setTimeout(function(){j=!0;m=null;("function"==typeof i.define&&i.define.amd?new Promise(function(a,c){i.require([b.default.iconsystemmodule],a,c)}):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&i.require&&"component"===i.require.loader?Promise.resolve(require((b.default.iconsystemmodule))):Promise.resolve(i[b.default.iconsystemmodule])).then(function(a){var b=new a;q(b.getTemplateName());return b}).then(function(a){n();a.init()}).catch()},500)},p=function(a){k=k.concat(a);o()},q=function(a){return p([a])},r=function(a,b){if(!l[a]){l[a]=[]}l[a]=l[a].concat(b);o()},s=function(a,b){if(!l[a]){l[a]=[]}l[a].push(b);o()};p([].concat(["core/loading"],["core/modal"],["core/modal_backdrop"]));r("core",["cancel","closebuttontitle","loading","savechanges"]);r("core_form",["showless","showmore"]);a.default={prefetchTemplate:q,prefetchTemplates:p,prefetchString:s,prefetchStrings:r};return a.default}); +define ("core/prefetch",["exports","core/config"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var i="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function c(a){return g(a)||f(a)||e(a)||d()}function d(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function e(a,b){if(!a)return;if("string"==typeof a)return h(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);if("Object"===c&&a.constructor)c=a.constructor.name;if("Map"===c||"Set"===c)return Array.from(c);if("Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c))return h(a,b)}function f(a){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a))return Array.from(a)}function g(a){if(Array.isArray(a))return h(a)}function h(a,b){if(null==b||b>a.length)b=a.length;for(var c=0,d=Array(b);c.\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 \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 (Config.jsrev <= 0) {\n // No point pre-fetching when cachejs is disabled as we do not store anything in the cache anyway.\n return;\n }\n\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"} \ No newline at end of file +{"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":"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","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 .\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 \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"} \ No newline at end of file diff --git a/lib/amd/build/templates.min.js b/lib/amd/build/templates.min.js index e9bf2bf3b10..c907e2bf2a0 100644 --- a/lib/amd/build/templates.min.js +++ b/lib/amd/build/templates.min.js @@ -1,2 +1,2 @@ -define ("core/templates",["core/mustache","jquery","core/ajax","core/str","core/notification","core/url","core/config","core/localstorage","core/icon_system","core/event","core/yui","core/log","core/truncate","core/user_date","core/pending"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=0,q={},r={},s={},t={},u=[],v=!1,w=["js"],x=function(a){if(0>=M.cfg.templaterev){return null}if(a in r){return r[a]}if(a in q){r[a]=b.Deferred().resolve(q[a]).promise();return r[a]}var c=h.get("core_template/"+M.cfg.templaterev+":"+a);if(c){q[a]=c;r[a]=b.Deferred().resolve(c).promise();return r[a]}return null},y=function(){if(!u.length){return}if(v){return}v=!0;var a=u.slice(),e=b.Deferred(),f=[],g=a.map(function(a){var c=a.component,i=a.name,j=a.searchKey,k=a.theme,l=a.deferred,m=null,n=x(j);if(n){m=n}else{f.push({methodname:"core_output_load_template_with_dependencies",args:{component:c,template:i,themename:k,lang:b("html").attr("lang").replace(/-/g,"_")}});var o=f.length-1;m=e.promise().then(function(a){g[j]=a[o].then(function(a){var b=null;a.templates.forEach(function(a){var d=[k,a.component,a.name].join("/");q[d]=a.value;h.set("core_template/"+M.cfg.templaterev+":"+d,a.value);if(a.component==c&&a.name==i){b=a.value}});if(a.strings.length){d.cache_strings(a.strings.map(function(a){return{component:a.component,key:a.name,value:a.value}}))}return b});return g[j]})}return m.then(function(a){return l.resolve(a)}).catch(function(a){l.reject(a);throw a})});if(f.length){e.resolve(c.call(f,!0,!1,!1,0,M.cfg.templaterev))}else{e.resolve()}b.when.apply(null,g).then(function(){u.splice(0,a.length);v=!1;y()}).catch(function(){u.splice(0,a.length);v=!1;y()})},z=function(){this.requiredStrings=[];this.requiredJS=[];this.requiredDates=[];this.currentThemeName=""};z.prototype.requiredStrings=null;z.prototype.requiredDates=[];z.prototype.requiredJS=null;z.prototype.currentThemeName="";z.prototype.getTemplate=function(a){var c=this.currentThemeName,d=c+"/"+a,e=x(d);if(e){return e}var f=u.filter(function(a){return a.searchKey==d});if(f.length){return f[0].deferred.promise()}var g=a.split("/"),h=g.shift(),i=g.join("/"),j=b.Deferred();u.push({component:h,name:i,theme:c,searchKey:d,deferred:j});y();return j.promise()};z.prototype.prefetchTemplates=function(a,c){a.forEach(function(a){var d=c+"/"+a;if(x(d)){return}var e=u.filter(function(a){return a.searchKey==d});if(e.length){return}var f=a.split("/"),g=f.shift(),h=f.join("/");u.push({component:g,name:h,theme:c,searchKey:d,deferred:b.Deferred()})});y()};z.prototype.partialHelper=function(a){var b=this.currentThemeName+"/"+a;if(!(b in q)){e.exception(new Error("Failed to pre-fetch the template: "+a))}return q[b]};z.prototype.renderIcon=function(a,c,d){var f=g.iconsystemmodule,h=b.Deferred();require([f],function(a){var b=new a;if(!(b instanceof i)){h.reject("Invalid icon system specified"+g.iconsystemmodule)}else{t=b;b.init().then(h.resolve).catch(e.exception)}});return h.then(function(a){return this.getTemplate(a.getTemplateName())}.bind(this)).then(function(b){return t.renderIcon(a,c,d,b)})};z.prototype.pixHelper=function(a,b,c){var d=b.split(","),e="",f="",g="";if(0=}}$1<%={{ }}=%>").replace(/(\r\n|\r|\n)/g," ");return"\""+d+"\""};z.prototype.shortenTextHelper=function(a,b,c){var d=b.match(/(.*?),(.*)/),e=d[1].trim(),f=d[2].trim(),g=c(f,a);return m.truncate(g,{length:e,words:!0,ellipsis:"..."})};z.prototype.userDateHelper=function(a,b,c){var d=b.match(/(.*?),(.*)/),e=c(d[1].trim(),a),f=c(d[2].trim(),a),g=this.requiredDates.length;this.requiredDates.push({timestamp:e,format:f});return"[[_t_"+g+"]]"};z.prototype.addHelperFunction=function(a,b){return function(){return function(c,d){var e=w.reduce(function(a,c){if(b.hasOwnProperty(c)){a[c]=b[c]}return a},{});w.forEach(function(a){b[a]=function(){return""}});var f=a.apply(this,[b,c,d]);for(var g in e){b[g]=e[g]}return f}.bind(this)}.bind(this)};z.prototype.addHelpers=function(a,b){this.currentThemeName=b;this.requiredStrings=[];this.requiredJS=[];a.uniqid=p++;a.str=this.addHelperFunction(this.stringHelper,a);a.pix=this.addHelperFunction(this.pixHelper,a);a.js=this.addHelperFunction(this.jsHelper,a);a.quote=this.addHelperFunction(this.quoteHelper,a);a.shortentext=this.addHelperFunction(this.shortenTextHelper,a);a.userdate=this.addHelperFunction(this.userDateHelper,a);a.globals={config:g};a.currentTheme=b};z.prototype.getJS=function(){var a="";if(0").attr("type","text/javascript").html(a);b("head").append(c)}},B=function(a,c,d,e){var f=b(a);if(f.length){var g=b(c),h=null;if(e){h=new k.NodeList(f.children().get());h.destroy(!0);f.empty();f.append(g)}else{h=new k.NodeList(f.get());h.destroy(!0);f.replaceWith(g)}A(d);j.notifyFilterContentUpdated(g)}};z.prototype.scanForPartials=function(b){var c=a.parse(b),d=[],e=function(a,b){var c,d;for(c=0;c"==d[0]||"<"==d[0]){b.push(d[1])}if(4=M.cfg.templaterev){return null}var c=h.get("core_template/"+M.cfg.templaterev+":"+a);if(c){q[a]=c;r[a]=b.Deferred().resolve(c).promise();return r[a]}return null},y=function(){if(!u.length){return}if(v){return}v=!0;var a=u.slice(),e=b.Deferred(),f=[],g=a.map(function(a){var c=a.component,i=a.name,j=a.searchKey,k=a.theme,l=a.deferred,m=null,n=x(j);if(n){m=n}else{f.push({methodname:"core_output_load_template_with_dependencies",args:{component:c,template:i,themename:k,lang:b("html").attr("lang").replace(/-/g,"_")}});var o=f.length-1;m=e.promise().then(function(a){g[j]=a[o].then(function(a){var b=null;a.templates.forEach(function(a){var d=[k,a.component,a.name].join("/");q[d]=a.value;if(0=}}$1<%={{ }}=%>").replace(/(\r\n|\r|\n)/g," ");return"\""+d+"\""};z.prototype.shortenTextHelper=function(a,b,c){var d=b.match(/(.*?),(.*)/),e=d[1].trim(),f=d[2].trim(),g=c(f,a);return m.truncate(g,{length:e,words:!0,ellipsis:"..."})};z.prototype.userDateHelper=function(a,b,c){var d=b.match(/(.*?),(.*)/),e=c(d[1].trim(),a),f=c(d[2].trim(),a),g=this.requiredDates.length;this.requiredDates.push({timestamp:e,format:f});return"[[_t_"+g+"]]"};z.prototype.addHelperFunction=function(a,b){return function(){return function(c,d){var e=w.reduce(function(a,c){if(b.hasOwnProperty(c)){a[c]=b[c]}return a},{});w.forEach(function(a){b[a]=function(){return""}});var f=a.apply(this,[b,c,d]);for(var g in e){b[g]=e[g]}return f}.bind(this)}.bind(this)};z.prototype.addHelpers=function(a,b){this.currentThemeName=b;this.requiredStrings=[];this.requiredJS=[];a.uniqid=p++;a.str=this.addHelperFunction(this.stringHelper,a);a.pix=this.addHelperFunction(this.pixHelper,a);a.js=this.addHelperFunction(this.jsHelper,a);a.quote=this.addHelperFunction(this.quoteHelper,a);a.shortentext=this.addHelperFunction(this.shortenTextHelper,a);a.userdate=this.addHelperFunction(this.userDateHelper,a);a.globals={config:g};a.currentTheme=b};z.prototype.getJS=function(){var a="";if(0").attr("type","text/javascript").html(a);b("head").append(c)}},B=function(a,c,d,e){var f=b(a);if(f.length){var g=b(c),h=null;if(e){h=new k.NodeList(f.children().get());h.destroy(!0);f.empty();f.append(g)}else{h=new k.NodeList(f.get());h.destroy(!0);f.replaceWith(g)}A(d);j.notifyFilterContentUpdated(g)}};z.prototype.scanForPartials=function(b){var c=a.parse(b),d=[],e=function(a,b){var c,d;for(c=0;c"==d[0]||"<"==d[0]){b.push(d[1])}if(4.\n\n/**\n * Template renderer for Moodle. Load and render Moodle templates with Mustache.\n *\n * @module core/templates\n * @package core\n * @class templates\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\ndefine([\n 'core/mustache',\n 'jquery',\n 'core/ajax',\n 'core/str',\n 'core/notification',\n 'core/url',\n 'core/config',\n 'core/localstorage',\n 'core/icon_system',\n 'core/event',\n 'core/yui',\n 'core/log',\n 'core/truncate',\n 'core/user_date',\n 'core/pending',\n ],\n function(mustache, $, ajax, str, notification, coreurl, config, storage, IconSystem, event, Y, Log, Truncate, UserDate,\n Pending) {\n\n // Module variables.\n /** @var {Number} uniqInstances Count of times this constructor has been called. */\n var uniqInstances = 0;\n\n /** @var {String[]} templateCache - Cache of already loaded template strings */\n var templateCache = {};\n\n /** @var {Promise[]} templatePromises - Cache of already loaded template promises */\n var templatePromises = {};\n\n /** @var {Promise[]} cachePartialPromises - Cache of already loaded template partial promises */\n var cachePartialPromises = {};\n\n /** @var {Object} iconSystem - Object extending core/iconsystem */\n var iconSystem = {};\n\n /** @var {Object[]} loadTemplateBuffer - List of templates to be loaded */\n var loadTemplateBuffer = [];\n\n /** @var {Bool} isLoadingTemplates - Whether templates are currently being loaded */\n var isLoadingTemplates = false;\n\n /** @var {Array} blacklistedNestedHelpers - List of helpers that can't be called within other helpers */\n var blacklistedNestedHelpers = ['js'];\n\n /**\n * Search the various caches for a template promise for the given search key.\n * The search key should be in the format //