WordPress.org

Make WordPress Core

Ticket #12186: background_js_fix.patch

File background_js_fix.patch, 3.6 KB (added by ocean90, 3 years ago)
  • wp-admin/custom-background.php

     
    156156<td> 
    157157<style type="text/css"> 
    158158#custom-background-image { 
     159        <?php if ( get_background_color() ) { ?> 
    159160        background-color: #<?php echo get_background_color()?>; 
    160         <?php if ( get_background_image() ) { ?> 
    161         background: url(<?php echo get_theme_mod('background_image_thumb', ''); ?>); 
     161        <?php } 
     162        if ( get_background_image() ) { ?> 
     163        background-image: url(<?php echo get_theme_mod('background_image_thumb', ''); ?>); 
    162164        background-repeat: <?php echo get_theme_mod('background_repeat', 'no-repeat'); ?>; 
    163165        background-position: top <?php echo get_theme_mod('background_position', 'left'); ?>; 
    164166        background-attachment: <?php echo get_theme_mod('background_position', 'fixed'); ?>; 
     
    221223<th scope="row"><?php _e( 'Background Color' ); ?></th> 
    222224<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend> 
    223225<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" /> 
    224 <input type="button" class="button" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" /> 
     226<input type="button" class="button hide-if-no-js" value="<?php esc_attr_e('Select a Color'); ?>" id="pickcolor" /> 
    225227 
    226228<div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 
    227229</fieldset></td> 
  • wp-admin/js/custom-background.dev.js

     
    1 var buttons = ['#pickcolor'], farbtastic; 
     1var farbtastic; 
    22 
    33function pickColor(color) { 
    44        jQuery('#background-color').val(color); 
    5         farbtastic.setColor(color); 
    65        jQuery('#custom-background-image').css('background-color', color); 
     6        farbtastic.setColor(color); 
    77} 
    88 
    99jQuery(document).ready(function() { 
    1010        jQuery('#pickcolor').click(function() { 
    1111                jQuery('#colorPickerDiv').show(); 
    1212        }); 
     13 
    1314        jQuery('#background-color').keyup(function() { 
    1415                var _hex = jQuery('#background-color').val(); 
    1516                var hex = _hex; 
     
    2122                if ( hex.length == 4 || hex.length == 7 ) 
    2223                        pickColor( hex ); 
    2324        }); 
     25 
    2426        jQuery('input[name="background-position"]').change(function() { 
    25                 jQuery('#custom-background-image').css('background-position', 'top '+jQuery(this).val()); 
     27                jQuery('#custom-background-image').css('background-position', 'top ' + jQuery(this).val()); 
    2628        }); 
     29 
    2730        jQuery('select[name="background-repeat"]').change(function() { 
    2831                jQuery('#custom-background-image').css('background-repeat', jQuery(this).val()); 
    2932        }); 
     
    3134        farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { 
    3235                pickColor(color); 
    3336        }); 
    34         pickColor(customBackgroundL10n.backgroundcolor); 
    35 }); 
     37        pickColor(jQuery('#background-color').val()); 
    3638 
    37 jQuery(document).mousedown(function(){ 
    38         hide_picker(); // Make the picker disappear if you click outside its div element 
    39 }); 
    40  
    41 function hide_picker(what) { 
    42         var update = false; 
    43         jQuery('#colorPickerDiv').each(function(){ 
    44                 var id = jQuery(this).attr('id'); 
    45                 if ( id == what ) 
    46                         return; 
    47  
    48                 var display = jQuery(this).css('display'); 
    49                 if ( display == 'block' ) 
    50                         jQuery(this).fadeOut(2); 
     39        jQuery(document).mousedown(function(){ 
     40                jQuery('#colorPickerDiv').each(function(){ 
     41                        var display = jQuery(this).css('display'); 
     42                        if ( display == 'block' ) 
     43                                jQuery(this).fadeOut(2); 
     44                }); 
    5145        }); 
    52 } 
    53  No newline at end of file 
     46});