{"version":3,"sources":["https:\/\/psagot-moodle.org\/lib\/amd\/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,CAAqB,CAACG,SAAtB,CAAkCC,MAAM,CAACC,MAAP,CAAcb,CAAU,CAACW,SAAzB,CAAlC,CAQAH,CAAqB,CAACG,SAAtB,CAAgCG,IAAhC,CAAuC,UAAW,CAC9C,GAAIR,CAAJ,CAAe,CACX,MAAOL,CAAAA,CAAC,CAACc,IAAF,CAAO,IAAP,CACV,CAED,GAAIC,CAAAA,CAAG,CAAGZ,CAAY,CAACa,GAAb,CAAiB,0BAAjB,CAAV,CACA,GAAID,CAAJ,CAAS,CACLA,CAAG,CAAGE,IAAI,CAACC,KAAL,CAAWH,CAAX,CACT,CAED,GAAIA,CAAJ,CAAS,CACLV,CAAS,CAAGU,CAAZ,CACA,MAAOf,CAAAA,CAAC,CAACc,IAAF,CAAO,IAAP,CACV,CAED,GAAiB,IAAb,GAAAR,CAAJ,CAAuB,CACnBA,CAAQ,CAAGL,C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P,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"}