{"version":3,"file":"icon_system_fontawesome.min.js","sources":["https:\/\/inclusivemediatraining.eu\/lib\/amd\/src\/icon_system_fontawesome.js"],"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 * @module core\/icon_system_fontawesome\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 * @class core\/icon_system_fontawesome\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"],"names":["define","IconSystem","$","Ajax","Mustache","LocalStorage","Url","staticMap","fetchMap","IconSystemFontawesome","apply","this","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","attributes","name","imageUrl","context","alt","render","trim","getTemplateName"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,mBAAoB,SAAU,YAAa,gBAAiB,oBAAqB,aACjF,SAASC,WAAYC,EAAGC,KAAMC,SAAUC,aAAcC,SAEt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