Make WordPress Core

Changeset 21004


Ignore:
Timestamp:
06/05/2012 06:57:49 PM (13 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/custom-background.dev.js

    r20944 r21004  
    33(function($) {
    44
    5     pickColor = function(color, cleared) {
     5    var defaultColor = '';
     6
     7    pickColor = function(color) {
    68        farbtastic.setColor(color);
    79        $('#background-color').val(color);
    810        $('#custom-background-image').css('background-color', color);
    9         console.log( color );
    10         if ( typeof cleared === 'undefined' )
    11             cleared = ! color || color === '#';
    12         if ( cleared )
     11        // If we have a default color, and they match, then we need to hide the 'Default' link.
     12        // Otherwise, we hide the 'Clear' link when it is empty.
     13        if ( ( defaultColor && color === defaultColor ) || ( ! defaultColor && ( '' === color || '#' === color ) ) )
    1314            $('#clearcolor').hide();
    1415        else
     
    1819    $(document).ready(function() {
    1920
     21        defaultColor = $('#defaultcolor').val();
     22
    2023        $('#pickcolor').click(function() {
    2124            $('#colorPickerDiv').show();
     
    2427
    2528        $('#clearcolor a').click( function(e) {
    26             pickColor( $('#defaultcolor').val(), true );
     29            pickColor( defaultColor );
    2730            e.preventDefault();
    2831        });
Note: See TracChangeset for help on using the changeset viewer.