diff --git a/lib/amd/build/icon_system_fontawesome.min.js b/lib/amd/build/icon_system_fontawesome.min.js index 47c4244203d06..10ffe0b6d6da3 100644 --- a/lib/amd/build/icon_system_fontawesome.min.js +++ b/lib/amd/build/icon_system_fontawesome.min.js @@ -1,2 +1,2 @@ -define ("core/icon_system_fontawesome",["core/icon_system","jquery","core/ajax","core/mustache","core/localstorage","core/url"],function(a,b,c,d,e,f){var g=null,h=null,i=function(){a.apply(this,arguments)};i.prototype=Object.create(a.prototype);i.prototype.init=function(){if(g){return b.when(this)}var a=e.get("core/iconmap-fontawesome");if(a){a=JSON.parse(a)}if(a){g=a;return b.when(this)}if(null===h){h=c.call([{methodname:"core_output_load_fontawesome_icon_system_map",args:{themename:M.cfg.theme}}],!0,!1,!1,0,M.cfg.themerev)[0]}return h.then(function(a){g={};b.each(a,function(a,b){g[b.component+"/"+b.pix]=b.to});e.set("core/iconmap-fontawesome",JSON.stringify(g));return this}.bind(this))};i.prototype.renderIcon=function(a,b,c,e){var h=g[b+"/"+a],i=!1;if("undefined"==typeof h){var j=f.imageUrl(a,b);i={attributes:[{name:"src",value:j},{name:"alt",value:c},{name:"title",value:c}]}}var k={key:h,title:c,alt:c,unmappedIcon:i};if("undefined"==typeof c||""===c){k["aria-hidden"]=!0}var l=d.render(e,k);return l.trim()};i.prototype.getTemplateName=function(){return"core/pix_icon_fontawesome"};return i}); +define ("core/icon_system_fontawesome",["core/icon_system","jquery","core/ajax","core/mustache","core/localstorage","core/url"],function(a,b,c,d,e,f){var g=null,h=null,i=function(){a.apply(this,arguments)};i.prototype=Object.create(a.prototype);i.prototype.init=function(){var a=M.cfg.theme;if(g){return b.when(this)}var d=e.get("core_iconsystem/theme/"+a+"/core/iconmap-fontawesome");if(d){d=JSON.parse(d)}if(d){g=d;return b.when(this)}if(null===h){h=c.call([{methodname:"core_output_load_fontawesome_icon_system_map",args:{themename:M.cfg.theme}}],!0,!1,!1,0,M.cfg.themerev)[0]}return h.then(function(c){g={};b.each(c,function(a,b){g[b.component+"/"+b.pix]=b.to});e.set("core_iconsystem/theme/"+a+"/core/iconmap-fontawesome",JSON.stringify(g));return this}.bind(this))};i.prototype.renderIcon=function(a,b,c,e){var h=g[b+"/"+a],i=!1;if("undefined"==typeof h){var j=f.imageUrl(a,b);i={attributes:[{name:"src",value:j},{name:"alt",value:c},{name:"title",value:c}]}}var k={key:h,title:c,alt:c,unmappedIcon:i};if("undefined"==typeof c||""===c){k["aria-hidden"]=!0}var l=d.render(e,k);return l.trim()};i.prototype.getTemplateName=function(){return"core/pix_icon_fontawesome"};return i}); //# sourceMappingURL=icon_system_fontawesome.min.js.map diff --git a/lib/amd/build/icon_system_fontawesome.min.js.map b/lib/amd/build/icon_system_fontawesome.min.js.map index 1bb4e1d699eed..374c798bd735a 100644 --- a/lib/amd/build/icon_system_fontawesome.min.js.map +++ b/lib/amd/build/icon_system_fontawesome.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/icon_system_fontawesome.js"],"names":["define","IconSystem","$","Ajax","Mustache","LocalStorage","Url","staticMap","fetchMap","IconSystemFontawesome","apply","arguments","prototype","Object","create","init","when","map","get","JSON","parse","call","methodname","args","themename","M","cfg","theme","themerev","then","each","index","value","component","pix","to","set","stringify","bind","renderIcon","key","title","template","mappedIcon","unmappedIcon","url","imageUrl","attributes","name","context","alt","result","render","trim","getTemplateName"],"mappings":"AAuBAA,OAAM,gCAAC,CAAC,kBAAD,CAAqB,QAArB,CAA+B,WAA/B,CAA4C,eAA5C,CAA6D,mBAA7D,CAAkF,UAAlF,CAAD,CACE,SAASC,CAAT,CAAqBC,CAArB,CAAwBC,CAAxB,CAA8BC,CAA9B,CAAwCC,CAAxC,CAAsDC,CAAtD,CAA2D,IAE3DC,CAAAA,CAAS,CAAG,IAF+C,CAG3DC,CAAQ,CAAG,IAHgD,CAQ3DC,CAAqB,CAAG,UAAW,CACnCR,CAAU,CAACS,KAAX,CAAiB,IAAjB,CAAuBC,SAAvB,CACH,CAV8D,CAW/DF,CAA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SAAtB,CAAgC2B,UAAhC,CAA6C,SAASC,CAAT,CAAcP,CAAd,CAAyBQ,CAAzB,CAAgCC,CAAhC,CAA0C,IAC/EC,CAAAA,CAAU,CAAGpC,CAAS,CAAC0B,CAAS,CAAG,GAAZ,CAAkBO,CAAnB,CADyD,CAE/EI,CAAY,GAFmE,CAGnF,GAA0B,WAAtB,QAAOD,CAAAA,CAAX,CAAuC,CACnC,GAAIE,CAAAA,CAAG,CAAGvC,CAAG,CAACwC,QAAJ,CAAaN,CAAb,CAAkBP,CAAlB,CAAV,CAEAW,CAAY,CAAG,CACXG,UAAU,CAAE,CACR,CAACC,IAAI,CAAE,KAAP,CAAchB,KAAK,CAAEa,CAArB,CADQ,CAER,CAACG,IAAI,CAAE,KAAP,CAAchB,KAAK,CAAES,CAArB,CAFQ,CAGR,CAACO,IAAI,CAAE,OAAP,CAAgBhB,KAAK,CAAES,CAAvB,CAHQ,CADD,CAOlB,CAED,GAAIQ,CAAAA,CAAO,CAAG,CACVT,GAAG,CAAEG,CADK,CAEVF,KAAK,CAAEA,CAFG,CAGVS,GAAG,CAAET,CAHK,CAIVG,YAAY,CAAEA,CAJJ,CAAd,CAOA,GAAqB,WAAjB,QAAOH,CAAAA,CAAP,EAA0C,EAAV,GAAAA,CAApC,CAAkD,CAC9CQ,CAAO,CAAC,aAAD,CAAP,GACH,CAED,GAAIE,CAAAA,CAAM,CAAG/C,CAAQ,CAACgD,MAAT,CAAgBV,CAAhB,CAA0BO,CAA1B,CAAb,CACA,MAAOE,CAAAA,CAAM,CAACE,IAAP,EACV,CA5BD,CAoCA5C,CAAqB,CAACG,SAAtB,CAAgC0C,eAAhC,CAAkD,UAAW,CACzD,MAAO,2BACV,CAFD,CAIA,MAAyD7C,CAAAA,CAE5D,CA1GK,CAAN","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 * Competency rule points module.\n *\n * @package core\n * @copyright 2017 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/localstorage', 'core/url'],\n function(IconSystem, $, Ajax, Mustache, LocalStorage, Url) {\n\n var staticMap = null;\n var fetchMap = null;\n\n /**\n * IconSystemFontawesome\n */\n var IconSystemFontawesome = function() {\n IconSystem.apply(this, arguments);\n };\n IconSystemFontawesome.prototype = Object.create(IconSystem.prototype);\n\n /**\n * Prefetch resources so later calls to renderIcon can be resolved synchronously.\n *\n * @method init\n * @return {Promise}\n */\n IconSystemFontawesome.prototype.init = function() {\n if (staticMap) {\n return $.when(this);\n }\n\n var map = LocalStorage.get('core/iconmap-fontawesome');\n if (map) {\n map = JSON.parse(map);\n }\n\n if (map) {\n staticMap = map;\n return $.when(this);\n }\n\n if (fetchMap === null) {\n fetchMap = Ajax.call([{\n methodname: 'core_output_load_fontawesome_icon_system_map',\n args: {\n themename: M.cfg.theme,\n },\n }], true, false, false, 0, M.cfg.themerev)[0];\n }\n\n return fetchMap.then(function(map) {\n staticMap = {};\n $.each(map, function(index, value) {\n staticMap[value.component + '/' + value.pix] = value.to;\n });\n LocalStorage.set('core/iconmap-fontawesome', JSON.stringify(staticMap));\n return this;\n }.bind(this));\n };\n\n /**\n * Render an icon.\n *\n * @param {String} key\n * @param {String} component\n * @param {String} title\n * @param {String} template\n * @return {String}\n * @method renderIcon\n */\n IconSystemFontawesome.prototype.renderIcon = function(key, component, title, template) {\n var mappedIcon = staticMap[component + '/' + key];\n var unmappedIcon = false;\n if (typeof mappedIcon === \"undefined\") {\n var url = Url.imageUrl(key, component);\n\n unmappedIcon = {\n attributes: [\n {name: 'src', value: url},\n {name: 'alt', value: title},\n {name: 'title', value: title}\n ]\n };\n }\n\n var context = {\n key: mappedIcon,\n title: title,\n alt: title,\n unmappedIcon: unmappedIcon\n };\n\n if (typeof title === \"undefined\" || title === '') {\n context['aria-hidden'] = true;\n }\n\n var result = Mustache.render(template, context);\n return result.trim();\n };\n\n /**\n * Get the name of the template to pre-cache for this icon system.\n *\n * @return {String}\n * @method getTemplateName\n */\n IconSystemFontawesome.prototype.getTemplateName = function() {\n return 'core/pix_icon_fontawesome';\n };\n\n return /** @alias module:core/icon_system_fontawesome */ IconSystemFontawesome;\n\n});\n"],"file":"icon_system_fontawesome.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/icon_system_fontawesome.js"],"names":["define","IconSystem","$","Ajax","Mustache","LocalStorage","Url","staticMap","fetchMap","IconSystemFontawesome","apply","arguments","prototype","Object","create","init","currTheme","M","cfg","theme","when","map","get","JSON","parse","call","methodname","args","themename","themerev","then","each","index","value","component","pix","to","set","stringify","bind","renderIcon","key","title","template","mappedIcon","unmappedIcon","url","imageUrl","attributes","name","context","alt","result","render","trim","getTemplateName"],"mappings":"AAuBAA,OAAM,gCAAC,CAAC,kBAAD,CAAqB,QAArB,CAA+B,WAA/B,CAA4C,eAA5C,CAA6D,mBAA7D,CAAkF,UAAlF,CAAD,CACE,SAASC,CAAT,CAAqBC,CAArB,CAAwBC,CAAxB,CAA8BC,CAA9B,CAAwCC,CAAxC,CAAsDC,CAAtD,CAA2D,IAE3DC,CAAAA,CAAS,CAAG,IAF+C,CAG3DC,CAAQ,CAAG,IAHgD,CAQ3DC,CAAqB,CAAG,UAAW,CACnCR,CAAU,CAACS,KAAX,CAAiB,IAAjB,CAAuBC,SAAvB,CACH,CAV8D,CAW/DF,CAAqB,CAACG,SAAtB,CAAkCC,MAAM,CAACC,MAAP,CAAcb,CAAU,CAACW,SAAzB,CAAlC,CAQAH,CAAqB,CAACG,SAAtB,C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B,CAAqB,CAACG,SAAtB,CAAgC4B,UAAhC,CAA6C,SAASC,CAAT,CAAcP,CAAd,CAAyBQ,CAAzB,CAAgCC,CAAhC,CAA0C,IAC/EC,CAAAA,CAAU,CAAGrC,CAAS,CAAC2B,CAAS,CAAG,GAAZ,CAAkBO,CAAnB,CADyD,CAE/EI,CAAY,GAFmE,CAGnF,GAA0B,WAAtB,QAAOD,CAAAA,CAAX,CAAuC,CACnC,GAAIE,CAAAA,CAAG,CAAGxC,CAAG,CAACyC,QAAJ,CAAaN,CAAb,CAAkBP,CAAlB,CAAV,CAEAW,CAAY,CAAG,CACXG,UAAU,CAAE,CACR,CAACC,IAAI,CAAE,KAAP,CAAchB,KAAK,CAAEa,CAArB,CADQ,CAER,CAACG,IAAI,CAAE,KAAP,CAAchB,KAAK,CAAES,CAArB,CAFQ,CAGR,CAACO,IAAI,CAAE,OAAP,CAAgBhB,KAAK,CAAES,CAAvB,CAHQ,CADD,CAOlB,CAED,GAAIQ,CAAAA,CAAO,CAAG,CACVT,GAAG,CAAEG,CADK,CAEVF,KAAK,CAAEA,CAFG,CAGVS,GAAG,CAAET,CAHK,CAIVG,YAAY,CAAEA,CAJJ,CAAd,CAOA,GAAqB,WAAjB,QAAOH,CAAAA,CAAP,EAA0C,EAAV,GAAAA,CAApC,CAAkD,CAC9CQ,CAAO,CAAC,aAAD,CAAP,GACH,CAED,GAAIE,CAAAA,CAAM,CAAGhD,CAAQ,CAACiD,MAAT,CAAgBV,CAAhB,CAA0BO,CAA1B,CAAb,CACA,MAAOE,CAAAA,CAAM,CAACE,IAAP,EACV,CA5BD,CAoCA7C,CAAqB,CAACG,SAAtB,CAAgC2C,eAAhC,CAAkD,UAAW,CACzD,MAAO,2BACV,CAFD,CAIA,MAAyD9C,CAAAA,CAE5D,CA5GK,CAAN","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 * Competency rule points module.\n *\n * @package core\n * @copyright 2017 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/localstorage', 'core/url'],\n function(IconSystem, $, Ajax, Mustache, LocalStorage, Url) {\n\n var staticMap = null;\n var fetchMap = null;\n\n /**\n * IconSystemFontawesome\n */\n var IconSystemFontawesome = function() {\n IconSystem.apply(this, arguments);\n };\n IconSystemFontawesome.prototype = Object.create(IconSystem.prototype);\n\n /**\n * Prefetch resources so later calls to renderIcon can be resolved synchronously.\n *\n * @method init\n * @return {Promise}\n */\n IconSystemFontawesome.prototype.init = function() {\n var currTheme = M.cfg.theme;\n\n if (staticMap) {\n return $.when(this);\n }\n\n var map = LocalStorage.get('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome');\n if (map) {\n map = JSON.parse(map);\n }\n\n if (map) {\n staticMap = map;\n return $.when(this);\n }\n\n if (fetchMap === null) {\n fetchMap = Ajax.call([{\n methodname: 'core_output_load_fontawesome_icon_system_map',\n args: {\n themename: M.cfg.theme,\n },\n }], true, false, false, 0, M.cfg.themerev)[0];\n }\n\n return fetchMap.then(function(map) {\n staticMap = {};\n $.each(map, function(index, value) {\n staticMap[value.component + '/' + value.pix] = value.to;\n });\n LocalStorage.set('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome', JSON.stringify(staticMap));\n return this;\n }.bind(this));\n };\n\n /**\n * Render an icon.\n *\n * @param {String} key\n * @param {String} component\n * @param {String} title\n * @param {String} template\n * @return {String}\n * @method renderIcon\n */\n IconSystemFontawesome.prototype.renderIcon = function(key, component, title, template) {\n var mappedIcon = staticMap[component + '/' + key];\n var unmappedIcon = false;\n if (typeof mappedIcon === \"undefined\") {\n var url = Url.imageUrl(key, component);\n\n unmappedIcon = {\n attributes: [\n {name: 'src', value: url},\n {name: 'alt', value: title},\n {name: 'title', value: title}\n ]\n };\n }\n\n var context = {\n key: mappedIcon,\n title: title,\n alt: title,\n unmappedIcon: unmappedIcon\n };\n\n if (typeof title === \"undefined\" || title === '') {\n context['aria-hidden'] = true;\n }\n\n var result = Mustache.render(template, context);\n return result.trim();\n };\n\n /**\n * Get the name of the template to pre-cache for this icon system.\n *\n * @return {String}\n * @method getTemplateName\n */\n IconSystemFontawesome.prototype.getTemplateName = function() {\n return 'core/pix_icon_fontawesome';\n };\n\n return /** @alias module:core/icon_system_fontawesome */ IconSystemFontawesome;\n\n});\n"],"file":"icon_system_fontawesome.min.js"} \ No newline at end of file diff --git a/lib/amd/src/icon_system_fontawesome.js b/lib/amd/src/icon_system_fontawesome.js index 25c749c7428dc..39c47114f670c 100644 --- a/lib/amd/src/icon_system_fontawesome.js +++ b/lib/amd/src/icon_system_fontawesome.js @@ -42,11 +42,13 @@ define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/locals * @return {Promise} */ IconSystemFontawesome.prototype.init = function() { + var currTheme = M.cfg.theme; + if (staticMap) { return $.when(this); } - var map = LocalStorage.get('core/iconmap-fontawesome'); + var map = LocalStorage.get('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome'); if (map) { map = JSON.parse(map); } @@ -70,7 +72,7 @@ define(['core/icon_system', 'jquery', 'core/ajax', 'core/mustache', 'core/locals $.each(map, function(index, value) { staticMap[value.component + '/' + value.pix] = value.to; }); - LocalStorage.set('core/iconmap-fontawesome', JSON.stringify(staticMap)); + LocalStorage.set('core_iconsystem/theme/' + currTheme + '/core/iconmap-fontawesome', JSON.stringify(staticMap)); return this; }.bind(this)); };