From 9aca3fb1287c12d901b0f9765cd9aa61c4151eaa Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 5 Jun 2012 18:57:49 +0000 Subject: [PATCH] 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 --- wp-admin/js/custom-background.dev.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/wp-admin/js/custom-background.dev.js b/wp-admin/js/custom-background.dev.js index 393c09f296..5bf085da2f 100644 --- a/wp-admin/js/custom-background.dev.js +++ b/wp-admin/js/custom-background.dev.js @@ -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(); });