Clean up the new svg-painter.js so that it passes our jshint; see #25858. Props jorbin.
Built from https://develop.svn.wordpress.org/trunk@26131 git-svn-id: http://core.svn.wordpress.org/trunk@26043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
821c6de4b6
commit
54c6e4c1e0
|
@ -1,4 +1,5 @@
|
|||
;var svgPainter = ( function( $, window, document, undefined ) {
|
||||
/* global mp6_color_scheme:true */
|
||||
var svgPainter = ( function( $, window, document, undefined ) {
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -30,7 +31,7 @@
|
|||
setColors : function( colors ) {
|
||||
|
||||
if ( typeof colors === 'undefined' && typeof mp6_color_scheme !== 'undefined' ) {
|
||||
var colors = mp6_color_scheme;
|
||||
colors = mp6_color_scheme;
|
||||
}
|
||||
|
||||
this.colorscheme = colors;
|
||||
|
@ -86,19 +87,20 @@
|
|||
if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) )
|
||||
return;
|
||||
|
||||
var xml = $element.data( 'mp6-svg-' + color );
|
||||
var xml = $element.data( 'mp6-svg-' + color ),
|
||||
base64;
|
||||
|
||||
if ( ! xml ) {
|
||||
|
||||
var base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ );
|
||||
base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ );
|
||||
|
||||
if ( ! base64 )
|
||||
return;
|
||||
|
||||
try {
|
||||
var xml = window.atob( base64[1] );
|
||||
xml = window.atob( base64[1] );
|
||||
} catch ( e ) {
|
||||
var xml = $.base64.atob( base64[1] );
|
||||
xml = $.base64.atob( base64[1] );
|
||||
}
|
||||
|
||||
// replace `fill` attributes
|
||||
|
@ -120,7 +122,7 @@
|
|||
|
||||
}
|
||||
|
||||
$element.attr( 'style', "background-image: url('data:image/svg+xml;base64," + xml + "') !important;" );
|
||||
$element.attr( 'style', 'background-image: url("data:image/svg+xml;base64,' + xml + '") !important;' );
|
||||
|
||||
}
|
||||
|
||||
|
@ -141,14 +143,15 @@
|
|||
**/
|
||||
;(function($) {
|
||||
|
||||
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
||||
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
||||
a256 = '',
|
||||
r64 = [256],
|
||||
r256 = [256],
|
||||
i = 0;
|
||||
i = 0,
|
||||
c, Plugin;
|
||||
|
||||
while(i < 256) {
|
||||
var c = String.fromCharCode(i);
|
||||
c = String.fromCharCode(i);
|
||||
a256 += c;
|
||||
r256[i] = i;
|
||||
r64[i] = b64.indexOf(c);
|
||||
|
@ -161,10 +164,11 @@
|
|||
i = 0,
|
||||
length = s.length,
|
||||
result = '',
|
||||
bitsInBuffer = 0;
|
||||
bitsInBuffer = 0,
|
||||
tmp;
|
||||
|
||||
while(i < length) {
|
||||
var c = s.charCodeAt(i);
|
||||
c = s.charCodeAt(i);
|
||||
c = c < 256 ? alpha[c] : -1;
|
||||
|
||||
buffer = (buffer << w1) + c;
|
||||
|
@ -172,7 +176,7 @@
|
|||
|
||||
while(bitsInBuffer >= w2) {
|
||||
bitsInBuffer -= w2;
|
||||
var tmp = buffer >> bitsInBuffer;
|
||||
tmp = buffer >> bitsInBuffer;
|
||||
result += beta.charAt(tmp);
|
||||
buffer ^= tmp << bitsInBuffer;
|
||||
}
|
||||
|
@ -182,7 +186,7 @@
|
|||
return result;
|
||||
}
|
||||
|
||||
var Plugin = $.base64 = function(dir, input, encode) {
|
||||
Plugin = $.base64 = function(dir, input, encode) {
|
||||
return input ? Plugin[dir](input, encode) : dir ? null : this;
|
||||
};
|
||||
|
||||
|
@ -191,8 +195,8 @@
|
|||
return plain + '===='.slice((plain.length % 4) || 4);
|
||||
};
|
||||
|
||||
$.base64.atob = function(coded, utf8decode) {
|
||||
coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
$.base64.atob = function(coded) {
|
||||
coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
||||
coded = String(coded).split('=');
|
||||
var i = coded.length;
|
||||
do {--i;
|
||||
|
|
|
@ -1 +1 @@
|
|||
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);
|
||||
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);
|
Loading…
Reference in New Issue