2013-11-13 10:26:10 -05:00
|
|
|
/* global mp6_color_scheme:true */
|
|
|
|
var svgPainter = ( function( $, window, document, undefined ) {
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
$(document).ready( function() {
|
|
|
|
|
|
|
|
// detection for browser SVG capability
|
|
|
|
if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
|
|
|
|
document.body.className = document.body.className.replace( 'no-svg', 'svg' );
|
|
|
|
}
|
|
|
|
|
|
|
|
svgPainter.init();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
elements : [],
|
|
|
|
|
|
|
|
init : function() {
|
|
|
|
|
|
|
|
this.selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' );
|
|
|
|
|
|
|
|
this.setColors();
|
|
|
|
this.findElements();
|
|
|
|
this.paint();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setColors : function( colors ) {
|
|
|
|
|
|
|
|
if ( typeof colors === 'undefined' && typeof mp6_color_scheme !== 'undefined' ) {
|
2013-11-13 10:26:10 -05:00
|
|
|
colors = mp6_color_scheme;
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
this.colorscheme = colors;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
findElements : function() {
|
|
|
|
|
|
|
|
this.selector.each(function() {
|
|
|
|
|
|
|
|
var bgimg = $(this).css( 'background-image' );
|
|
|
|
|
|
|
|
if ( bgimg.indexOf( 'data:image/svg+xml;base64' ) != -1 ) {
|
|
|
|
svgPainter.elements.push( $(this) );
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
paint : function() {
|
|
|
|
|
|
|
|
// loop through all elements
|
|
|
|
$.each( this.elements, function( index, $element ) {
|
|
|
|
|
|
|
|
var $menuitem = $element.parent().parent();
|
|
|
|
|
|
|
|
if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) {
|
|
|
|
|
|
|
|
// paint icon in 'current' color
|
|
|
|
svgPainter.paintElement( $element, svgPainter.colorscheme.icons.current );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// paint icon in base color
|
|
|
|
svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base );
|
|
|
|
|
|
|
|
// set hover callbacks
|
|
|
|
$menuitem.hover(
|
|
|
|
function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.focus ); },
|
|
|
|
function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base ); }
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
paintElement : function( $element, color ) {
|
|
|
|
|
|
|
|
// only accept hex colors: #101 or #101010
|
|
|
|
if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) )
|
|
|
|
return;
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
var xml = $element.data( 'mp6-svg-' + color ),
|
|
|
|
base64;
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
if ( ! xml ) {
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ );
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
if ( ! base64 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
2013-11-13 10:26:10 -05:00
|
|
|
xml = window.atob( base64[1] );
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
} catch ( e ) {
|
2013-11-13 10:26:10 -05:00
|
|
|
xml = $.base64.atob( base64[1] );
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// replace `fill` attributes
|
|
|
|
xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"');
|
|
|
|
|
|
|
|
// replace `style` attributes
|
|
|
|
xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"');
|
|
|
|
|
|
|
|
// replace `fill` properties in `<style>` tags
|
|
|
|
xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';');
|
|
|
|
|
|
|
|
try {
|
|
|
|
xml = window.btoa( xml );
|
|
|
|
} catch ( e ) {
|
|
|
|
xml = $.base64.btoa( xml );
|
|
|
|
}
|
|
|
|
|
|
|
|
$element.data( 'mp6-svg-' + color, xml );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
$element.attr( 'style', 'background-image: url("data:image/svg+xml;base64,' + xml + '") !important;' );
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
})( jQuery, window, document );
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Customized for MP6
|
|
|
|
*
|
|
|
|
* Based on jquery.base64.js 0.0.3 - https://github.com/yckart/jquery.base64.js
|
|
|
|
*
|
|
|
|
* Based upon: https://gist.github.com/Yaffle/1284012
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Yannick Albert (http://yckart.com)
|
|
|
|
* Licensed under the MIT license
|
|
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
|
|
**/
|
|
|
|
;(function($) {
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
a256 = '',
|
|
|
|
r64 = [256],
|
|
|
|
r256 = [256],
|
2013-11-13 10:26:10 -05:00
|
|
|
i = 0,
|
|
|
|
c, Plugin;
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
while(i < 256) {
|
2013-11-13 10:26:10 -05:00
|
|
|
c = String.fromCharCode(i);
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
a256 += c;
|
|
|
|
r256[i] = i;
|
|
|
|
r64[i] = b64.indexOf(c);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
function code(s, discard, alpha, beta, w1, w2) {
|
|
|
|
s = String(s);
|
|
|
|
var buffer = 0,
|
|
|
|
i = 0,
|
|
|
|
length = s.length,
|
|
|
|
result = '',
|
2013-11-13 10:26:10 -05:00
|
|
|
bitsInBuffer = 0,
|
|
|
|
tmp;
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
|
|
|
|
while(i < length) {
|
2013-11-13 10:26:10 -05:00
|
|
|
c = s.charCodeAt(i);
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
c = c < 256 ? alpha[c] : -1;
|
|
|
|
|
|
|
|
buffer = (buffer << w1) + c;
|
|
|
|
bitsInBuffer += w1;
|
|
|
|
|
|
|
|
while(bitsInBuffer >= w2) {
|
|
|
|
bitsInBuffer -= w2;
|
2013-11-13 10:26:10 -05:00
|
|
|
tmp = buffer >> bitsInBuffer;
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
result += beta.charAt(tmp);
|
|
|
|
buffer ^= tmp << bitsInBuffer;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
Plugin = $.base64 = function(dir, input, encode) {
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
return input ? Plugin[dir](input, encode) : dir ? null : this;
|
|
|
|
};
|
|
|
|
|
|
|
|
$.base64.btoa = function(plain) {
|
|
|
|
plain = code(plain, false, r256, b64, 8, 6);
|
|
|
|
return plain + '===='.slice((plain.length % 4) || 4);
|
|
|
|
};
|
|
|
|
|
2013-11-13 10:26:10 -05:00
|
|
|
$.base64.atob = function(coded) {
|
|
|
|
coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
Say hello to a fresh new look for the WordPress admin.
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
2013-11-09 19:27:10 -05:00
|
|
|
coded = String(coded).split('=');
|
|
|
|
var i = coded.length;
|
|
|
|
do {--i;
|
|
|
|
coded[i] = code(coded[i], true, r64, a256, 6, 8);
|
|
|
|
} while (i > 0);
|
|
|
|
coded = coded.join('');
|
|
|
|
return coded;
|
|
|
|
};
|
|
|
|
}(jQuery));
|