mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 14:45:45 +01:00
0347a8944e
Props yoavf, TobiasBg. Fixes #26073. Built from https://develop.svn.wordpress.org/trunk@27053 git-svn-id: http://core.svn.wordpress.org/trunk@26927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
2.4 KiB
JavaScript
1 line
2.4 KiB
JavaScript
window.wp=window.wp||{},wp.svgPainter=function(a,b,c){"use strict";var d,e,f,g={},h=[];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"),wp.svgPainter.init())}),e=function(){function a(){for(;256>j;)e=String.fromCharCode(j),g+=e,i[j]=j,h[j]=f.indexOf(e),++j}function b(a,b,c,d,f,g){var h,i,j=0,k=0,l="",m=0;for(a=String(a),i=a.length;i>k;){for(e=a.charCodeAt(k),e=256>e?c[e]:-1,j=(j<<f)+e,m+=f;m>=g;)m-=g,h=j>>m,l+=d.charAt(h),j^=h<<m;++k}return!b&&m>0&&(l+=d.charAt(j<<g-m)),l}function c(c){return e||a(),c=b(c,!1,i,f,8,6),c+"====".slice(c.length%4||4)}function d(c){var d;e||a(),c=c.replace(/[^A-Za-z0-9\+\/\=]/g,""),c=String(c).split("="),d=c.length;do--d,c[d]=b(c[d],!0,h,g,6,8);while(d>0);return c=c.join("")}var e,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="",h=[256],i=[256],j=0;return{atob:d,btoa:c}}(),{init:function(){f=this,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&&(g=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")&&h.push(b)})},paint:function(){a.each(h,function(a,c){var d=c.parent().parent();d.hasClass("current")||d.hasClass("wp-has-current-submenu")?f.paintElement(c,"current"):(f.paintElement(c,"base"),d.hover(function(){f.paintElement(c,"focus")},function(){b.setTimeout(function(){f.paintElement(c,"base")},100)}))})},paintElement:function(a,c){var d,f,h;if(c&&g.hasOwnProperty(c)&&(h=g[c],h.match(/^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i)&&(d=a.data("wp-ui-svg-"+h),"none"!==d))){if(!d){if(f=a.css("background-image").match(/.+data:image\/svg\+xml;base64,([A-Za-z0-9\+\/\=]+)/),!f||!f[1])return void a.data("wp-ui-svg-"+h,"none");try{d="atob"in b?b.atob(f[1]):e.atob(f[1])}catch(i){}if(!d)return void a.data("wp-ui-svg-"+h,"none");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.attr("style",'background-image: url("data:image/svg+xml;base64,'+d+'") !important;')}}}}(jQuery,window,document); |