mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-12 15:48:34 +02:00
Still to come: more color schemes, a responsive component, and more. see #25858. props iammattthomas, tillkruess, EmpireOfLight, melchoyce, ryelle, joen, mitchoyoshitaka, sirbrillig, andypeatling, isaackeyet, Otto42, dd32, matt, helen. Built from https://develop.svn.wordpress.org/trunk@26072 git-svn-id: http://core.svn.wordpress.org/trunk@25992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
2.4 KiB
JavaScript
1 line
2.4 KiB
JavaScript
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){if("undefined"==typeof a&&"undefined"!=typeof mp6_color_scheme)var 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=c.data("mp6-svg-"+d);if(!e){var f=c.css("background-image").match(/.+data:image\/svg\+xml;base64,(.+)\)/);if(!f)return;try{var e=b.atob(f[1])}catch(g){var e=a.base64.atob(f[1])}e=e.replace(/fill="(.+?)"/g,'fill="'+d+'"'),e=e.replace(/style="(.+?)"/g,'style="fill:'+d+'"'),e=e.replace(/fill:.*?;/g,"fill: "+d+";");try{e=b.btoa(e)}catch(g){e=a.base64.btoa(e)}c.data("mp6-svg-"+d,e)}c.attr("style","background-image: url('data:image/svg+xml;base64,"+e+"') !important;")}}}}(jQuery,window,document);!function(a){function b(a,b,c,d,e,f){a=String(a);for(var g=0,h=0,i=a.length,j="",k=0;i>h;){var l=a.charCodeAt(h);for(l=256>l?c[l]:-1,g=(g<<e)+l,k+=e;k>=f;){k-=f;var m=g>>k;j+=d.charAt(m),g^=m<<k}++h}return!b&&k>0&&(j+=d.charAt(g<<f-k)),j}for(var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="",e=[256],f=[256],g=0;256>g;){var h=String.fromCharCode(g);d+=h,f[g]=g,e[g]=c.indexOf(h),++g}var i=a.base64=function(a,b,c){return b?i[a](b,c):a?null:this};a.base64.btoa=function(a){return a=b(a,!1,f,c,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,e,d,6,8);while(c>0);return a=a.join("")}}(jQuery); |