diff --git a/wp-admin/custom-background.php b/wp-admin/custom-background.php index 34fcd019b..5bd996b75 100644 --- a/wp-admin/custom-background.php +++ b/wp-admin/custom-background.php @@ -294,8 +294,9 @@ if ( get_background_image() ) {
+ - + class="hide-if-no-js" id="clearcolor"> ()
diff --git a/wp-admin/js/custom-background.dev.js b/wp-admin/js/custom-background.dev.js index 1a46d55d0..b4dbc6657 100644 --- a/wp-admin/js/custom-background.dev.js +++ b/wp-admin/js/custom-background.dev.js @@ -4,6 +4,10 @@ function pickColor(color) { farbtastic.setColor(color); jQuery('#background-color').val(color); jQuery('#custom-background-image').css('background-color', color); + if ( color && color !== '#' ) + jQuery('#clearcolor').show(); + else + jQuery('#clearcolor').hide(); } jQuery(document).ready(function() { @@ -12,6 +16,11 @@ jQuery(document).ready(function() { return false; }); + jQuery('#clearcolor a').click( function(e) { + pickColor(''); + e.preventDefault(); + }); + jQuery('#background-color').keyup(function() { var _hex = jQuery('#background-color').val(), hex = _hex; if ( hex.charAt(0) != '#' ) diff --git a/wp-admin/js/custom-background.js b/wp-admin/js/custom-background.js index d7aecbcdd..6cf8851bd 100644 --- a/wp-admin/js/custom-background.js +++ b/wp-admin/js/custom-background.js @@ -1 +1 @@ -var farbtastic;function pickColor(a){farbtastic.setColor(a);jQuery("#background-color").val(a);jQuery("#custom-background-image").css("background-color",a)}jQuery(document).ready(function(){jQuery("#pickcolor").click(function(){jQuery("#colorPickerDiv").show();return false});jQuery("#background-color").keyup(function(){var b=jQuery("#background-color").val(),a=b;if(a.charAt(0)!="#"){a="#"+a}a=a.replace(/[^#a-fA-F0-9]+/,"");if(a!=b){jQuery("#background-color").val(a)}if(a.length==4||a.length==7){pickColor(a)}});jQuery('input[name="background-position-x"]').change(function(){jQuery("#custom-background-image").css("background-position",jQuery(this).val()+" top")});jQuery('input[name="background-repeat"]').change(function(){jQuery("#custom-background-image").css("background-repeat",jQuery(this).val())});farbtastic=jQuery.farbtastic("#colorPickerDiv",function(a){pickColor(a)});pickColor(jQuery("#background-color").val());jQuery(document).mousedown(function(){jQuery("#colorPickerDiv").each(function(){var a=jQuery(this).css("display");if(a=="block"){jQuery(this).fadeOut(2)}})})}); \ No newline at end of file +var farbtastic;function pickColor(a){farbtastic.setColor(a);jQuery("#background-color").val(a);jQuery("#custom-background-image").css("background-color",a);if(a&&a!=="#"){jQuery("#clearcolor").show()}else{jQuery("#clearcolor").hide()}}jQuery(document).ready(function(){jQuery("#pickcolor").click(function(){jQuery("#colorPickerDiv").show();return false});jQuery("#clearcolor a").click(function(a){pickColor("");a.preventDefault()});jQuery("#background-color").keyup(function(){var b=jQuery("#background-color").val(),a=b;if(a.charAt(0)!="#"){a="#"+a}a=a.replace(/[^#a-fA-F0-9]+/,"");if(a!=b){jQuery("#background-color").val(a)}if(a.length==4||a.length==7){pickColor(a)}});jQuery('input[name="background-position-x"]').change(function(){jQuery("#custom-background-image").css("background-position",jQuery(this).val()+" top")});jQuery('input[name="background-repeat"]').change(function(){jQuery("#custom-background-image").css("background-repeat",jQuery(this).val())});farbtastic=jQuery.farbtastic("#colorPickerDiv",function(a){pickColor(a)});pickColor(jQuery("#background-color").val());jQuery(document).mousedown(function(){jQuery("#colorPickerDiv").each(function(){var a=jQuery(this).css("display");if(a=="block"){jQuery(this).fadeOut(2)}})})}); \ No newline at end of file