MDL-70106 cache: Set icon localstorage cache to use theme localisation

This commit is contained in:
Peter Burnett 2020-11-03 10:59:21 +10:00
parent 58ba94a729
commit 7fe1554c21
3 changed files with 6 additions and 4 deletions

View File

@ -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

File diff suppressed because one or more lines are too long

View File

@ -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));
};