Preview by default the registered default image for custom backgrounds. props mfields, billerickson.

If there is a default color registered, show a 'Default' action rather than a 'Clear' action, as clearing the value would simply return to the default.

Make current_theme_supports() accept a second argument for 'custom-background' requests, the same as get_theme_support(). Missed in earlier changes, see #20249.

fixes #20734, fixes #18041.



git-svn-id: https://develop.svn.wordpress.org/trunk@20901 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2012-05-25 17:58:57 +00:00
parent efefd513c3
commit 85eb57bd89
3 changed files with 66 additions and 56 deletions
+58 -50
View File
@@ -1,55 +1,63 @@
var farbtastic;
var farbtastic, pickColor;
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();
}
(function($) {
jQuery(document).ready(function() {
jQuery('#pickcolor').click(function() {
jQuery('#colorPickerDiv').show();
return false;
});
pickColor = function(color, cleared) {
farbtastic.setColor(color);
$('#background-color').val(color);
$('#custom-background-image').css('background-color', color);
console.log( color );
if ( typeof cleared === 'undefined' )
cleared = ! color || color === '#';
if ( cleared )
$('#clearcolor').hide();
else
$('#clearcolor').show();
}
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) != '#' )
hex = '#' + hex;
hex = hex.replace(/[^#a-fA-F0-9]+/, '');
if ( hex != _hex )
jQuery('#background-color').val(hex);
if ( hex.length == 4 || hex.length == 7 )
pickColor( hex );
});
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(color) {
pickColor(color);
});
pickColor(jQuery('#background-color').val());
jQuery(document).mousedown(function(){
jQuery('#colorPickerDiv').each(function(){
var display = jQuery(this).css('display');
if ( display == 'block' )
jQuery(this).fadeOut(2);
$(document).ready(function() {
$('#pickcolor').click(function() {
$('#colorPickerDiv').show();
return false;
});
$('#clearcolor a').click( function(e) {
pickColor( $('#defaultcolor').val(), true );
e.preventDefault();
});
$('#background-color').keyup(function() {
var _hex = $('#background-color').val(), hex = _hex;
if ( hex.charAt(0) != '#' )
hex = '#' + hex;
hex = hex.replace(/[^#a-fA-F0-9]+/, '');
if ( hex != _hex )
$('#background-color').val(hex);
if ( hex.length == 4 || hex.length == 7 )
pickColor( hex );
});
$('input[name="background-position-x"]').change(function() {
$('#custom-background-image').css('background-position', $(this).val() + ' top');
});
$('input[name="background-repeat"]').change(function() {
$('#custom-background-image').css('background-repeat', $(this).val());
});
farbtastic = $.farbtastic('#colorPickerDiv', function(color) {
pickColor(color);
});
pickColor($('#background-color').val());
$(document).mousedown(function(){
$('#colorPickerDiv').each(function(){
var display = $(this).css('display');
if ( display == 'block' )
$(this).fadeOut(2);
});
});
});
});
})(jQuery);