Adding autosave for color schemes and removing RTL handling. See #26387, props ryelle.

Built from https://develop.svn.wordpress.org/trunk@26746


git-svn-id: http://core.svn.wordpress.org/trunk@26634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Matt Thomas 2013-12-06 21:26:10 +00:00
parent 03ab0cc95f
commit e0957c8eb7
3 changed files with 12 additions and 10 deletions

View File

@ -81,15 +81,17 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<div>
<h3><?php echo ( 'Pick a color' ); ?></h3>
<p><?php echo ( 'We&#8217;ve included four color schemes so that you can choose your favorite. Don&#8217;t like this striking new admin? Choose from any of the schemes below to change it in an instant.' ); ?></p>
<?php $user_id = get_current_user_id(); ?>
<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) :?>
<?php
wp_nonce_field('update-user_' . $user_id);
/** This action is documented in wp-admin/user-edit.php */
do_action( 'admin_color_scheme_picker' );
?>
<?php else : ?>
<img src="<?php echo admin_url( 'images/about-color-schemes.png' ); ?>" />
<?php endif; ?>
<p><?php printf( ( 'To change your color scheme later, just <a href="%1$s">visit your profile settings</a>.' ), get_edit_profile_url( get_current_user_id() ) ); ?></p>
<p><?php printf( ( 'To change your color scheme later, just <a href="%1$s">visit your profile settings</a>.' ), get_edit_profile_url( $user_id ) ); ?></p>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
/* global isRtl */
/* global ajaxurl */
(function($){
$(document).ready( function() {
@ -10,9 +10,6 @@
$colorpicker = $( '#color-picker' );
$stylesheet = $( '#colors-css' );
if ( isRtl ){
$stylesheet = $( '#colors-rtl-css' );
}
$colorpicker.on( 'click.colorpicker', '.color-option', function() {
var colors, css_url,
@ -28,10 +25,6 @@
// Set color scheme
// Load the colors stylesheet
css_url = $this.children( '.css_url' ).val();
if ( isRtl ){
css_url = css_url.replace('.min', '-rtl.min');
}
$stylesheet.attr( 'href', css_url );
// repaint icons
@ -45,6 +38,13 @@
wp.svgPainter.paint();
}
}
// update user option
$.post( ajaxurl, {
action: 'save-user-color-scheme',
color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
nonce: $('#_wpnonce').val()
});
});
});

View File

@ -1 +1 @@
!function(a){a(document).ready(function(){var b,c;a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",!0)}),b=a("#color-picker"),c=a("#colors-css"),isRtl&&(c=a("#colors-rtl-css")),b.on("click.colorpicker",".color-option",function(){var b,d,e=a(this);if(!e.hasClass("selected")&&(e.siblings(".selected").removeClass("selected"),e.addClass("selected").find('input[type="radio"]').prop("checked",!0),d=e.children(".css_url").val(),isRtl&&(d=d.replace(".min","-rtl.min")),c.attr("href",d),"undefined"!=typeof wp&&wp.svgPainter)){try{b=a.parseJSON(e.children(".icon_colors").val())}catch(f){}b&&(wp.svgPainter.setColors(b),wp.svgPainter.paint())}})})}(jQuery);
!function(a){a(document).ready(function(){var b,c;a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",!0)}),b=a("#color-picker"),c=a("#colors-css"),b.on("click.colorpicker",".color-option",function(){var b,d,e=a(this);if(!e.hasClass("selected")){if(e.siblings(".selected").removeClass("selected"),e.addClass("selected").find('input[type="radio"]').prop("checked",!0),d=e.children(".css_url").val(),c.attr("href",d),"undefined"!=typeof wp&&wp.svgPainter){try{b=a.parseJSON(e.children(".icon_colors").val())}catch(f){}b&&(wp.svgPainter.setColors(b),wp.svgPainter.paint())}a.post(ajaxurl,{action:"save-user-color-scheme",color_scheme:e.children('input[name="admin_color"]').val(),nonce:a("#_wpnonce").val()})}})})}(jQuery);