diff --git a/lib/amd/build/str.min.js b/lib/amd/build/str.min.js index a644679659c..3f33a1bc8c0 100644 --- a/lib/amd/build/str.min.js +++ b/lib/amd/build/str.min.js @@ -1,2 +1,2 @@ -define ("core/str",["exports","jquery","core/ajax","core/localstorage"],function(a,b,c,d){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.cache_strings=a.get_strings=a.get_string=void 0;b=e(b);c=e(c);d=e(d);function e(a){return a&&a.__esModule?a:{default:a}}function f(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);if(b)d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable});c.push.apply(c,d)}return c}function g(a){for(var b=1,c;b.\n\n/**\n * Fetch and render language strings.\n * Hooks into the old M.str global - but can also fetch missing strings on the fly.\n *\n * @module core/str\n * @class str\n * @package core\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport LocalStorage from 'core/localstorage';\n\n// Module cache for the promises so that we don't make multiple\n// unnecessary requests.\nlet promiseCache = [];\n\n/**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_string\n * @param {string} key The language string key\n * @param {string} component The language string component\n * @param {string} param The param for variable expansion in the string.\n * @param {string} lang The users language - if not passed it is deduced.\n * @return {Promise}\n */\nexport const get_string = (key, component, param, lang) => {\n return get_strings([{key, component, param, lang}])\n .then(results => results[0]);\n};\n\n/**\n * Make a batch request to load a set of strings\n *\n * @method get_strings\n * @param {Object[]} requests Array of { key: key, component: component, param: param, lang: lang };\n * See get_string for more info on these args.\n * @return {Promise}\n */\nexport const get_strings = (requests) => {\n let requestData = [];\n const pageLang = $('html').attr('lang').replace(/-/g, '_');\n // Helper function to construct the cache key.\n const getCacheKey = ({key, component, lang = pageLang}) => `core_str/${key}/${component}/${lang}`;\n\n const stringPromises = requests.map((request) => {\n const cacheKey = getCacheKey(request);\n const {component, key, param, lang = pageLang} = request;\n // Helper function to add the promise to cache.\n const buildReturn = (promise) => {\n // Make sure the promise cache contains our promise.\n promiseCache[cacheKey] = promise;\n return promise;\n };\n\n // Check if we can serve the string straight from M.str.\n if (component in M.str && key in M.str[component]) {\n return buildReturn(new Promise((resolve) => {\n resolve(M.util.get_string(key, component, param, lang));\n }));\n }\n\n // Check if the string is in the browser's local storage.\n const cached = LocalStorage.get(cacheKey);\n if (cached) {\n M.str[component] = {...M.str[component], [key]: cached};\n return buildReturn(new Promise((resolve) => {\n resolve(M.util.get_string(key, component, param, lang));\n }));\n }\n\n // Check if we've already loaded this string from the server.\n if (cacheKey in promiseCache) {\n return buildReturn(promiseCache[cacheKey]).then(() => {\n return M.util.get_string(key, component, param, lang);\n });\n } else {\n // We're going to have to ask the server for the string so\n // add this string to the list of requests to be sent.\n return buildReturn(new Promise((resolve, reject) => {\n requestData.push({\n methodname: 'core_get_string',\n args: {\n stringid: key,\n stringparams: [],\n component,\n lang,\n },\n done: (str) => {\n // When we get the response from the server\n // we should update M.str and the browser's\n // local storage before resolving this promise.\n M.str[component] = {...M.str[component], [key]: str};\n LocalStorage.set(cacheKey, str);\n resolve(M.util.get_string(key, component, param, lang));\n },\n fail: reject\n });\n }));\n }\n });\n\n if (requestData.length) {\n // If we need to load any strings from the server then send\n // off the request.\n Ajax.call(requestData, true, false, false, 0, M.cfg.langrev);\n }\n\n // We need to use jQuery here because some calling code uses the\n // .done handler instead of the .then handler.\n return $.when.apply($, stringPromises)\n .then((...strings) => strings);\n};\n\n/**\n * Add a list of strings to the caches.\n *\n * @method cache_strings\n * @param {Object[]} strings Array of { key: key, component: component, lang: lang, value: value }\n */\nexport const cache_strings = (strings) => {\n const defaultLang = $('html').attr('lang').replace(/-/g, '_');\n\n strings.forEach(({key, component, value, lang = defaultLang}) => {\n const cacheKey = ['core_str', key, component, lang].join('/');\n\n // Check M.str caching.\n if (!(component in M.str) || !(key in M.str[component])) {\n if (!(component in M.str)) {\n M.str[component] = {};\n }\n\n M.str[component][key] = value;\n }\n\n // Check local storage.\n if (!LocalStorage.get(cacheKey)) {\n LocalStorage.set(cacheKey, value);\n }\n\n // Check the promises cache.\n if (!(cacheKey in promiseCache)) {\n promiseCache[cacheKey] = $.Deferred().resolve(value).promise();\n }\n });\n};\n"],"file":"str.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/str.js"],"names":["promiseCache","get_string","key","component","param","lang","get_strings","then","results","requests","requestData","pageLang","attr","replace","getCacheKey","stringPromises","map","request","cacheKey","buildReturn","promise","M","str","Promise","resolve","util","cached","LocalStorage","get","reject","push","methodname","args","stringid","stringparams","done","set","fail","length","Ajax","call","cfg","langrev","$","when","apply","strings","cache_strings","defaultLang","forEach","value","join","Deferred"],"mappings":"0MA0BA,OACA,OACA,O,iwBAIIA,CAAAA,CAAY,CAAG,E,cAYO,QAAbC,CAAAA,UAAa,CAACC,CAAD,CAAMC,CAAN,CAAiBC,CAAjB,CAAwBC,CAAxB,CAAiC,CACvD,MAAOC,CAAAA,CAAW,CAAC,CAAC,CAACJ,GAAG,CAAHA,CAAD,CAAMC,SAAS,CAATA,CAAN,CAAiBC,KAAK,CAALA,CAAjB,CAAwBC,IAAI,CAAJA,CAAxB,CAAD,CAAD,CAAX,CACFE,IADE,CACG,SAAAC,CAAO,QAAIA,CAAAA,CAAO,CAAC,CAAD,CAAX,CADV,CAEV,C,CAUM,GAAMF,CAAAA,CAAW,CAAG,SAACG,CAAD,CAAc,IACjCC,CAAAA,CAAW,CAAG,EADmB,CAE/BC,CAAQ,CAAG,cAAE,MAAF,EAAUC,IAAV,CAAe,MAAf,EAAuBC,OAAvB,CAA+B,IAA/B,CAAqC,GAArC,CAFoB,CAI/BC,CAAW,CAAG,WAAuC,IAArCZ,CAAAA,CAAqC,GAArCA,GAAqC,CAAhCC,CAAgC,GAAhCA,SAAgC,KAArBE,IAAqB,CAArBA,CAAqB,YAAdM,CAAc,GACvD,GAAI,CAACR,CAAL,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,QAAF,GAAa5B,OAAb,CAAqB0B,CAArB,EAA4B9B,OAA5B,EAC5B,CACJ,CArBD,CAsBH,CAzBM,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 .\n\n/**\n * Fetch and render language strings.\n * Hooks into the old M.str global - but can also fetch missing strings on the fly.\n *\n * @module core/str\n * @class str\n * @package core\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since 2.9\n */\nimport $ from 'jquery';\nimport Ajax from 'core/ajax';\nimport LocalStorage from 'core/localstorage';\n\n// Module cache for the promises so that we don't make multiple\n// unnecessary requests.\nlet promiseCache = [];\n\n/**\n * Return a promise object that will be resolved into a string eventually (maybe immediately).\n *\n * @method get_string\n * @param {string} key The language string key\n * @param {string} component The language string component\n * @param {string} param The param for variable expansion in the string.\n * @param {string} lang The users language - if not passed it is deduced.\n * @return {Promise}\n */\nexport const get_string = (key, component, param, lang) => {\n return get_strings([{key, component, param, lang}])\n .then(results => results[0]);\n};\n\n/**\n * Make a batch request to load a set of strings\n *\n * @method get_strings\n * @param {Object[]} requests Array of { key: key, component: component, param: param, lang: lang };\n * See get_string for more info on these args.\n * @return {Promise}\n */\nexport const get_strings = (requests) => {\n let requestData = [];\n const pageLang = $('html').attr('lang').replace(/-/g, '_');\n // Helper function to construct the cache key.\n const getCacheKey = ({key, component, lang = pageLang}) => {\n if (!component) {\n component = 'core';\n }\n return `core_str/${key}/${component}/${lang}`;\n };\n\n const stringPromises = requests.map((request) => {\n const cacheKey = getCacheKey(request);\n const {component, key, param, lang = pageLang} = request;\n // Helper function to add the promise to cache.\n const buildReturn = (promise) => {\n // Make sure the promise cache contains our promise.\n promiseCache[cacheKey] = promise;\n return promise;\n };\n\n // Check if we can serve the string straight from M.str.\n if (component in M.str && key in M.str[component]) {\n return buildReturn(new Promise((resolve) => {\n resolve(M.util.get_string(key, component, param, lang));\n }));\n }\n\n // Check if the string is in the browser's local storage.\n const cached = LocalStorage.get(cacheKey);\n if (cached) {\n M.str[component] = {...M.str[component], [key]: cached};\n return buildReturn(new Promise((resolve) => {\n resolve(M.util.get_string(key, component, param, lang));\n }));\n }\n\n // Check if we've already loaded this string from the server.\n if (cacheKey in promiseCache) {\n return buildReturn(promiseCache[cacheKey]).then(() => {\n return M.util.get_string(key, component, param, lang);\n });\n } else {\n // We're going to have to ask the server for the string so\n // add this string to the list of requests to be sent.\n return buildReturn(new Promise((resolve, reject) => {\n requestData.push({\n methodname: 'core_get_string',\n args: {\n stringid: key,\n stringparams: [],\n component,\n lang,\n },\n done: (str) => {\n // When we get the response from the server\n // we should update M.str and the browser's\n // local storage before resolving this promise.\n M.str[component] = {...M.str[component], [key]: str};\n LocalStorage.set(cacheKey, str);\n resolve(M.util.get_string(key, component, param, lang));\n },\n fail: reject\n });\n }));\n }\n });\n\n if (requestData.length) {\n // If we need to load any strings from the server then send\n // off the request.\n Ajax.call(requestData, true, false, false, 0, M.cfg.langrev);\n }\n\n // We need to use jQuery here because some calling code uses the\n // .done handler instead of the .then handler.\n return $.when.apply($, stringPromises)\n .then((...strings) => strings);\n};\n\n/**\n * Add a list of strings to the caches.\n *\n * @method cache_strings\n * @param {Object[]} strings Array of { key: key, component: component, lang: lang, value: value }\n */\nexport const cache_strings = (strings) => {\n const defaultLang = $('html').attr('lang').replace(/-/g, '_');\n\n strings.forEach(({key, component, value, lang = defaultLang}) => {\n const cacheKey = ['core_str', key, component, lang].join('/');\n\n // Check M.str caching.\n if (!(component in M.str) || !(key in M.str[component])) {\n if (!(component in M.str)) {\n M.str[component] = {};\n }\n\n M.str[component][key] = value;\n }\n\n // Check local storage.\n if (!LocalStorage.get(cacheKey)) {\n LocalStorage.set(cacheKey, value);\n }\n\n // Check the promises cache.\n if (!(cacheKey in promiseCache)) {\n promiseCache[cacheKey] = $.Deferred().resolve(value).promise();\n }\n });\n};\n"],"file":"str.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 c907e2bf2a0..24665b18e2b 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(a in r){return r[a]}if(a in q){r[a]=b.Deferred().resolve(q[a]).promise();return r[a]}if(0>=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=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 //