WordPress/wp-includes/js/svg-painter.min.js

1 line
2.3 KiB
JavaScript
Raw Normal View History

var svgPainter=function(a,b,c){"use strict";return a(c).ready(function(){c.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1")&&(c.body.className=c.body.className.replace("no-svg","svg")),svgPainter.init()}),{elements:[],init:function(){this.selector=a("#adminmenu .wp-menu-image, #wpadminbar .ab-item"),this.setColors(),this.findElements(),this.paint()},setColors:function(a){"undefined"==typeof a&&"undefined"!=typeof mp6_color_scheme&&(a=mp6_color_scheme),this.colorscheme=a},findElements:function(){this.selector.each(function(){var b=a(this).css("background-image");-1!=b.indexOf("data:image/svg+xml;base64")&&svgPainter.elements.push(a(this))})},paint:function(){a.each(this.elements,function(a,b){var c=b.parent().parent();c.hasClass("current")||c.hasClass("wp-has-current-submenu")?svgPainter.paintElement(b,svgPainter.colorscheme.icons.current):(svgPainter.paintElement(b,svgPainter.colorscheme.icons.base),c.hover(function(){svgPainter.paintElement(b,svgPainter.colorscheme.icons.focus)},function(){svgPainter.paintElement(b,svgPainter.colorscheme.icons.base)}))})},paintElement:function(c,d){if(d.match(/^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i)){var e,f=c.data("mp6-svg-"+d);if(!f){if(e=c.css("background-image").match(/.+data:image\/svg\+xml;base64,(.+)\)/),!e)return;try{f=b.atob(e[1])}catch(g){f=a.base64.atob(e[1])}f=f.replace(/fill="(.+?)"/g,'fill="'+d+'"'),f=f.replace(/style="(.+?)"/g,'style="fill:'+d+'"'),f=f.replace(/fill:.*?;/g,"fill: "+d+";");try{f=b.btoa(f)}catch(g){f=a.base64.btoa(f)}c.data("mp6-svg-"+d,f)}c.attr("style",'background-image: url("data:image/svg+xml;base64,'+f+'") !important;')}}}}(jQuery,window,document);!function(a){function b(a,b,d,e,f,g){a=String(a);for(var h,i=0,j=0,k=a.length,l="",m=0;k>j;){for(c=a.charCodeAt(j),c=256>c?d[c]:-1,i=(i<<f)+c,m+=f;m>=g;)m-=g,h=i>>m,l+=e.charAt(h),i^=h<<m;++j}return!b&&m>0&&(l+=e.charAt(i<<g-m)),l}for(var c,d,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f="",g=[256],h=[256],i=0;256>i;)c=String.fromCharCode(i),f+=c,h[i]=i,g[i]=e.indexOf(c),++i;d=a.base64=function(a,b,c){return b?d[a](b,c):a?null:this},a.base64.btoa=function(a){return a=b(a,!1,h,e,8,6),a+"====".slice(a.length%4||4)},a.base64.atob=function(a){a=a.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=String(a).split("=");var c=a.length;do--c,a[c]=b(a[c],!0,g,f,6,8);while(c>0);return a=a.join("")}}(jQuery);