Ticket #26333: 26333.patch
File 26333.patch, 6.4 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-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, 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 } 12 13 svgPainter.init();14 15 13 }); 16 14 17 15 return { 16 init: function() { 17 selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' ); 18 18 19 elements : [],20 21 init : function() {22 23 this.selector = $( '#adminmenu .wp-menu-image, #wpadminbar .ab-item' );24 25 19 this.setColors(); 26 20 this.findElements(); 27 21 this.paint(); 28 29 22 }, 30 23 31 setColors : function( colors ) { 24 setColors: function( colors ) { 25 if ( typeof colors === 'undefined' && typeof window._wpColorScheme !== 'undefined' ) { 26 colors = window._wpColorScheme; 27 } 32 28 33 if ( typeof colors === 'undefined' && typeof wp_color_scheme !== 'undefined') {34 colors = wp_color_scheme;29 if ( colors && colors.icons && colors.icons.base && colors.icons.current && colors.icons.focus ) { 30 colorscheme = colors.icons; 35 31 } 36 37 this.colorscheme = colors;38 39 32 }, 40 33 41 findElements : function() { 34 findElements: function() { 35 selector.each( function() { 36 var $this = $(this), bgImage = $this.css( 'background-image' ); 42 37 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) ); 38 if ( bgImage && bgImage.indexOf( 'data:image/svg+xml;base64' ) != -1 ) { 39 elements.push( $this ); 49 40 } 50 51 41 }); 52 53 42 }, 54 43 55 paint : function() { 44 paint: function() { 45 if ( ! colorscheme ) { 46 return; 47 } 56 48 57 49 // loop through all elements 58 $.each( this.elements, function( index, $element ) { 59 50 $.each( elements, function( index, $element ) { 60 51 var $menuitem = $element.parent().parent(); 61 52 62 53 if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) { 63 64 54 // paint icon in 'current' color 65 svgPainter.paintElement( $element, svgPainter.colorscheme.icons.current ); 66 55 svgPainter.paintElement( $element, 'current' ); 67 56 } else { 68 69 57 // paint icon in base color 70 svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base);58 svgPainter.paintElement( $element, 'base' ); 71 59 72 60 // set hover callbacks 73 61 $menuitem.hover( 74 function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.focus); },75 function() { svgPainter.paintElement( $element, svgPainter.colorscheme.icons.base); }62 function() { svgPainter.paintElement( $element, 'focus' ); }, 63 function() { svgPainter.paintElement( $element, 'base' ); } 76 64 ); 77 78 65 } 79 80 66 }); 81 82 67 }, 83 68 84 paintElement : function( $element, color ) { 69 paintElement: function( $element, colorType ) { 70 var xml, base64, color; 85 71 72 if ( ! colorType || ! colorscheme.hasOwnProperty( colorType ) ) { 73 return; 74 } 75 76 color = colorscheme[ colorType ]; 77 86 78 // only accept hex colors: #101 or #101010 87 if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) 79 if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) { 88 80 return; 81 } 89 82 90 var xml = $element.data( 'mp6-svg-' + color ), 91 base64; 83 xml = $element.data( 'mp6-svg-' + color ); 92 84 93 85 if ( ! xml ) { 94 95 86 base64 = $element.css( 'background-image' ).match( /.+data:image\/svg\+xml;base64,(.+)\)/ ); 96 87 97 if ( ! base64 ) 88 if ( ! base64 ) { 98 89 return; 90 } 99 91 100 92 try { 101 93 xml = window.atob( base64[1] ); … … 119 111 } 120 112 121 113 $element.data( 'mp6-svg-' + color, xml ); 122 123 114 } 124 115 125 116 $element.attr( 'style', 'background-image: url("data:image/svg+xml;base64,' + xml + '") !important;' ); 126 127 117 } 128 118 129 119 }; -
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