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