Custom background color: Show the 'Default' link when the input is empty and there is a default color registered. fixes #20448. see #20734.

git-svn-id: http://core.svn.wordpress.org/trunk@21004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2012-06-05 18:57:49 +00:00
parent 3ebea2f218
commit fff6be1510
1 changed files with 9 additions and 6 deletions

View File

@ -2,14 +2,15 @@ var farbtastic, pickColor;
(function($) {
pickColor = function(color, cleared) {
var defaultColor = '';
pickColor = function(color) {
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 )
// If we have a default color, and they match, then we need to hide the 'Default' link.
// Otherwise, we hide the 'Clear' link when it is empty.
if ( ( defaultColor && color === defaultColor ) || ( ! defaultColor && ( '' === color || '#' === color ) ) )
$('#clearcolor').hide();
else
$('#clearcolor').show();
@ -17,13 +18,15 @@ var farbtastic, pickColor;
$(document).ready(function() {
defaultColor = $('#defaultcolor').val();
$('#pickcolor').click(function() {
$('#colorPickerDiv').show();
return false;
});
$('#clearcolor a').click( function(e) {
pickColor( $('#defaultcolor').val(), true );
pickColor( defaultColor );
e.preventDefault();
});