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: https://develop.svn.wordpress.org/trunk@21004 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-06-05 18:57:49 +00:00
parent 245b0655d2
commit 9aca3fb128
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();
});