Ticket #26333: 26333.2.patch
File 26333.2.patch, 12.6 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/misc.php
613 613 <?php 614 614 } 615 615 616 function set_color_scheme_json() {616 function wp_color_scheme_settings() { 617 617 global $_wp_admin_css_colors; 618 618 619 619 $color_scheme = get_user_option( 'admin_color' ); 620 620 621 if ( isset( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {622 echo '<script type="text/javascript">var wp_color_scheme = ' . json_encode( array( 'icons' => $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) . ";</script>\n";621 if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) { 622 echo '<script type="text/javascript">var _wpColorScheme = ' . json_encode( array( 'icons' => $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) . ";</script>\n"; 623 623 } 624 624 } 625 add_action( 'admin_head', ' set_color_scheme_json' );625 add_action( 'admin_head', 'wp_color_scheme_settings' ); 626 626 627 627 function _ipad_meta() { 628 628 if ( wp_is_mobile() ) { -
src/wp-admin/js/user-profile.js
83 83 current_user_id = $( 'input[name="checkuser_id"]' ).val(); 84 84 85 85 $colorpicker.on( 'click.colorpicker', '.color-option', function() { 86 var $this = $(this); 86 var colors, 87 $this = $(this); 87 88 88 89 if ( $this.hasClass( 'selected' ) ) { 89 90 return; … … 99 100 100 101 // repaint icons 101 102 if ( typeof window.svgPainter !== 'undefined' ) { 102 svgPainter.setColors( $.parseJSON( $this.children( '.icon_colors' ).val() ) ); 103 svgPainter.paint(); 103 try { 104 colors = $.parseJSON( $this.children( '.icon_colors' ).val() ); 105 } catch ( error ) {} 106 107 if ( colors ) { 108 svgPainter.setColors( colors ); 109 svgPainter.paint(); 110 } 104 111 } 105 112 106 113 // update user option -
src/wp-includes/general-template.php
2117 2117 function register_admin_color_schemes() { 2118 2118 wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), 2119 2119 admin_url( 'css/colors-fresh.min.css' ), 2120 array( '#222', '#333', '#0074a2', '#2ea2cc' ) 2120 array( '#222', '#333', '#0074a2', '#2ea2cc' ), 2121 array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' ) 2121 2122 ); 2122 2123 2123 2124 // Other color schemes are not available when running out of src -
src/wp-includes/js/svg-painter.js
1 1 /* global wp_color_scheme:true */ 2 2 var svgPainter = ( function( $, window, document, undefined ) { 3 4 3 'use strict'; 4 var colorscheme, selector, base64, 5 elements = []; 5 6 6 7 $(document).ready( function() { 7 8 8 // detection for browser SVG capability 9 9 if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) { 10 document.body.className = document.body.className.replace( 'no-svg', 'svg' ); 10 $( document.body ).removeClass( 'no-svg' ).addClass( 'svg' ); 11 svgPainter.init(); 11 12 } 13 }); 12 14 13 svgPainter.init(); 15 /** 16 * Needed only for IE9 17 * 18 * Based on jquery.base64.js 0.0.3 - https://github.com/yckart/jquery.base64.js 19 * 20 * Based on: https://gist.github.com/Yaffle/1284012 21 * 22 * Copyright (c) 2012 Yannick Albert (http://yckart.com) 23 * Licensed under the MIT license 24 * http://www.opensource.org/licenses/mit-license.php 25 */ 26 base64 = ( function() { 27 var c, 28 b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', 29 a256 = '', 30 r64 = [256], 31 r256 = [256], 32 i = 0; 14 33 15 }); 34 while( i < 256 ) { 35 c = String.fromCharCode(i); 36 a256 += c; 37 r256[i] = i; 38 r64[i] = b64.indexOf(c); 39 ++i; 40 } 16 41 17 return { 42 function code( s, discard, alpha, beta, w1, w2 ) { 43 var tmp, length, 44 buffer = 0, 45 i = 0, 46 result = '', 47 bitsInBuffer = 0; 18 48 19 elements : [], 49 s = String(s); 50 length = s.length; 20 51 21 init : function() { 52 while( i < length ) { 53 c = s.charCodeAt(i); 54 c = c < 256 ? alpha[c] : -1; 22 55 23 this.selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' ); 56 buffer = ( buffer << w1 ) + c; 57 bitsInBuffer += w1; 24 58 59 while( bitsInBuffer >= w2 ) { 60 bitsInBuffer -= w2; 61 tmp = buffer >> bitsInBuffer; 62 result += beta.charAt(tmp); 63 buffer ^= tmp << bitsInBuffer; 64 } 65 ++i; 66 } 67 68 if ( ! discard && bitsInBuffer > 0 ) { 69 result += beta.charAt( buffer << ( w2 - bitsInBuffer ) ); 70 } 71 72 return result; 73 } 74 75 function btoa( plain ) { 76 plain = code( plain, false, r256, b64, 8, 6 ); 77 return plain + '===='.slice( ( plain.length % 4 ) || 4 ); 78 } 79 80 function atob( coded ) { 81 var i; 82 83 coded = coded.replace( /[^A-Za-z0-9\+\/\=]/g, '' ); 84 coded = String(coded).split('='); 85 i = coded.length; 86 87 do { 88 --i; 89 coded[i] = code( coded[i], true, r64, a256, 6, 8 ); 90 } while ( i > 0 ); 91 92 coded = coded.join(''); 93 return coded; 94 } 95 96 return { 97 atob: atob, 98 btoa: btoa 99 }; 100 })(); 101 102 return { 103 init: function() { 104 selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' ); 105 25 106 this.setColors(); 26 107 this.findElements(); 27 108 this.paint(); 28 29 109 }, 30 110 31 setColors : function( colors ) { 111 setColors: function( colors ) { 112 if ( typeof colors === 'undefined' && typeof window._wpColorScheme !== 'undefined' ) { 113 colors = window._wpColorScheme; 114 } 32 115 33 if ( typeof colors === 'undefined' && typeof wp_color_scheme !== 'undefined') {34 colors = wp_color_scheme;116 if ( colors && colors.icons && colors.icons.base && colors.icons.current && colors.icons.focus ) { 117 colorscheme = colors.icons; 35 118 } 36 37 this.colorscheme = colors;38 39 119 }, 40 120 41 findElements : function() { 121 findElements: function() { 122 selector.each( function() { 123 var $this = $(this), bgImage = $this.css( 'background-image' ); 42 124 43 this.selector.each(function() { 44 45 var bgimg = $(this).css( 'background-image' ); 46 47 if ( bgimg.indexOf( 'data:image/svg+xml;base64' ) != -1 ) { 48 svgPainter.elements.push( $(this) ); 125 if ( bgImage && bgImage.indexOf( 'data:image/svg+xml;base64' ) != -1 ) { 126 elements.push( $this ); 49 127 } 50 51 128 }); 52 53 129 }, 54 130 55 paint : function() { 131 paint: function() { 132 if ( ! colorscheme ) { 133 return; 134 } 56 135 57 136 // loop through all elements 58 $.each( this.elements, function( index, $element ) { 59 137 $.each( elements, function( index, $element ) { 60 138 var $menuitem = $element.parent().parent(); 61 139 62 140 if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) { 63 64 141 // paint icon in 'current' color 65 svgPainter.paintElement( $element, svgPainter.colorscheme.icons.current ); 66 142 svgPainter.paintElement( $element, 'current' ); 67 143 } else { 68 69 144 // paint icon in base color 70 svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base);145 svgPainter.paintElement( $element, 'base' ); 71 146 72 147 // set hover callbacks 73 148 $menuitem.hover( 74 function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.focus); },75 function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base); }149 function() { svgPainter.paintElement( $element, 'focus' ); }, 150 function() { svgPainter.paintElement( $element, 'base' ); } 76 151 ); 77 78 152 } 79 80 153 }); 81 82 154 }, 83 155 84 paintElement : function( $element, color ) { 156 paintElement: function( $element, colorType ) { 157 var xml, encoded, color; 85 158 159 if ( ! colorType || ! colorscheme.hasOwnProperty( colorType ) ) { 160 return; 161 } 162 163 color = colorscheme[ colorType ]; 164 86 165 // only accept hex colors: #101 or #101010 87 if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) 166 if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) { 88 167 return; 168 } 89 169 90 var xml = $element.data( 'mp6-svg-' + color ), 91 base64; 170 xml = $element.data( 'mp6-svg-' + color ); 92 171 93 172 if ( ! xml ) { 173 encoded = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+?)['"]\)/ ); 94 174 95 base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ ); 96 97 if ( ! base64 ) 175 if ( ! encoded || ! encoded[1] ) { 98 176 return; 177 } 99 178 100 try{101 xml = window.atob( base64[1] );102 } catch ( e ){103 xml = $.base64.atob( base64[1] );179 if ( 'atob' in window ) { 180 xml = window.atob( encoded[1] ); 181 } else { 182 xml = base64.atob( encoded[1] ); 104 183 } 105 184 106 185 // replace `fill` attributes … … 112 191 // replace `fill` properties in `<style>` tags 113 192 xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';'); 114 193 115 try{194 if ( 'btoa' in window ) { 116 195 xml = window.btoa( xml ); 117 } catch ( e ){118 xml = $.base64.btoa( xml );196 } else { 197 xml = base64.btoa( xml ); 119 198 } 120 199 121 200 $element.data( 'mp6-svg-' + color, xml ); 122 123 201 } 124 202 125 203 $element.attr( 'style', 'background-image: url("data:image/svg+xml;base64,' + xml + '") !important;' ); 126 127 204 } 128 129 205 }; 130 206 131 207 })( jQuery, window, document ); 132 133 /*!134 * Customized for MP6135 *136 * Based on jquery.base64.js 0.0.3 - https://github.com/yckart/jquery.base64.js137 *138 * Based upon: https://gist.github.com/Yaffle/1284012139 *140 * Copyright (c) 2012 Yannick Albert (http://yckart.com)141 * Licensed under the MIT license142 * http://www.opensource.org/licenses/mit-license.php143 **/144 ;(function($) {145 146 var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',147 a256 = '',148 r64 = [256],149 r256 = [256],150 i = 0,151 c, Plugin;152 153 while(i < 256) {154 c = String.fromCharCode(i);155 a256 += c;156 r256[i] = i;157 r64[i] = b64.indexOf(c);158 ++i;159 }160 161 function code(s, discard, alpha, beta, w1, w2) {162 s = String(s);163 var buffer = 0,164 i = 0,165 length = s.length,166 result = '',167 bitsInBuffer = 0,168 tmp;169 170 while(i < length) {171 c = s.charCodeAt(i);172 c = c < 256 ? alpha[c] : -1;173 174 buffer = (buffer << w1) + c;175 bitsInBuffer += w1;176 177 while(bitsInBuffer >= w2) {178 bitsInBuffer -= w2;179 tmp = buffer >> bitsInBuffer;180 result += beta.charAt(tmp);181 buffer ^= tmp << bitsInBuffer;182 }183 ++i;184 }185 if(!discard && bitsInBuffer > 0) result += beta.charAt(buffer << (w2 - bitsInBuffer));186 return result;187 }188 189 Plugin = $.base64 = function(dir, input, encode) {190 return input ? Plugin[dir](input, encode) : dir ? null : this;191 };192 193 $.base64.btoa = function(plain) {194 plain = code(plain, false, r256, b64, 8, 6);195 return plain + '===='.slice((plain.length % 4) || 4);196 };197 198 $.base64.atob = function(coded) {199 coded = coded.replace(/[^A-Za-z0-9\+\/\=]/g, '');200 coded = String(coded).split('=');201 var i = coded.length;202 do {--i;203 coded[i] = code(coded[i], true, r64, a256, 6, 8);204 } while (i > 0);205 coded = coded.join('');206 return coded;207 };208 }(jQuery)); -
src/wp-includes/script-loader.php
392 392 $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 ); 393 393 $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models' ), false, 1 ); 394 394 395 $scripts->add( 'svg-painter', '/wp-includes/js/svg-painter.js' );396 397 395 if ( is_admin() ) { 398 396 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array('jquery', 'wp-ajax-response'), false, 1 ); 399 397 did_action( 'init' ) && $scripts->localize( 'admin-tags', 'tagsl10n', array( … … 516 514 $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); 517 515 $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker', 'media-views' ), false, 1 ); 518 516 $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); 517 518 $scripts->add( 'svg-painter', '/wp-includes/js/svg-painter.js', array( 'jquery' ), false, 1 ); 519 519 } 520 520 } 521 521