Changeset 20901
- Timestamp:
- 05/25/2012 05:58:57 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/custom-background.php
r20885 r20901 208 208 if ( get_background_image() ) { 209 209 // background-image URL must be single quote, see below 210 $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', '') ) . '\');'210 $background_styles .= ' background-image: url(\'' . set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ) . '\');' 211 211 . ' background-repeat: ' . get_theme_mod('background_repeat', 'repeat') . ';' 212 212 . ' background-position: top ' . get_theme_mod('background_position_x', 'left'); … … 215 215 <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?> 216 216 <?php if ( get_background_image() ) { ?> 217 <img class="custom-background-image" src="<?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', '') ); ?>" style="visibility:hidden;" alt="" /><br />218 <img class="custom-background-image" src="<?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', '') ); ?>" style="visibility:hidden;" alt="" />217 <img class="custom-background-image" src="<?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ); ?>" style="visibility:hidden;" alt="" /><br /> 218 <img class="custom-background-image" src="<?php echo set_url_scheme( get_theme_mod( 'background_image_thumb', get_background_image() ) ); ?>" style="visibility:hidden;" alt="" /> 219 219 <?php } ?> 220 220 </div> … … 323 323 <th scope="row"><?php _e( 'Background Color' ); ?></th> 324 324 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend> 325 <?php $show_clear = get_ background_color() ? '' : ' style="display:none"'; ?>325 <?php $show_clear = get_theme_mod('background_color') ? '' : ' style="display:none"'; ?> 326 326 <input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()) ?>" /> 327 <a class="hide-if-no-js" href="#" id="pickcolor"><?php _e('Select a Color'); ?></a> <span<?php echo $show_clear; ?> class="hide-if-no-js" id="clearcolor"> (<a href="#"><?php _e( 'Clear' ); ?></a>)</span> 327 <a class="hide-if-no-js" href="#" id="pickcolor"><?php _e('Select a Color'); ?></a> <span<?php echo $show_clear; ?> class="hide-if-no-js" id="clearcolor"> (<a href="#"><?php current_theme_supports( 'custom-background', 'default-color' ) ? _e( 'Default' ) : _e( 'Clear' ); ?></a>)</span> 328 <input type="hidden" id="defaultcolor" value="<?php if ( current_theme_supports( 'custom-background', 'default-color' ) ) echo '#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ); ?>" /> 328 329 <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> 329 330 </fieldset></td> -
trunk/wp-admin/js/custom-background.dev.js
r17886 r20901 1 var farbtastic ;1 var farbtastic, pickColor; 2 2 3 function pickColor(color) { 4 farbtastic.setColor(color); 5 jQuery('#background-color').val(color); 6 jQuery('#custom-background-image').css('background-color', color); 7 if ( color && color !== '#' ) 8 jQuery('#clearcolor').show(); 9 else 10 jQuery('#clearcolor').hide(); 11 } 3 (function($) { 12 4 13 jQuery(document).ready(function() { 14 jQuery('#pickcolor').click(function() { 15 jQuery('#colorPickerDiv').show(); 16 return false; 5 pickColor = function(color, cleared) { 6 farbtastic.setColor(color); 7 $('#background-color').val(color); 8 $('#custom-background-image').css('background-color', color); 9 console.log( color ); 10 if ( typeof cleared === 'undefined' ) 11 cleared = ! color || color === '#'; 12 if ( cleared ) 13 $('#clearcolor').hide(); 14 else 15 $('#clearcolor').show(); 16 } 17 18 $(document).ready(function() { 19 20 $('#pickcolor').click(function() { 21 $('#colorPickerDiv').show(); 22 return false; 23 }); 24 25 $('#clearcolor a').click( function(e) { 26 pickColor( $('#defaultcolor').val(), true ); 27 e.preventDefault(); 28 }); 29 30 $('#background-color').keyup(function() { 31 var _hex = $('#background-color').val(), hex = _hex; 32 if ( hex.charAt(0) != '#' ) 33 hex = '#' + hex; 34 hex = hex.replace(/[^#a-fA-F0-9]+/, ''); 35 if ( hex != _hex ) 36 $('#background-color').val(hex); 37 if ( hex.length == 4 || hex.length == 7 ) 38 pickColor( hex ); 39 }); 40 41 $('input[name="background-position-x"]').change(function() { 42 $('#custom-background-image').css('background-position', $(this).val() + ' top'); 43 }); 44 45 $('input[name="background-repeat"]').change(function() { 46 $('#custom-background-image').css('background-repeat', $(this).val()); 47 }); 48 49 farbtastic = $.farbtastic('#colorPickerDiv', function(color) { 50 pickColor(color); 51 }); 52 pickColor($('#background-color').val()); 53 54 $(document).mousedown(function(){ 55 $('#colorPickerDiv').each(function(){ 56 var display = $(this).css('display'); 57 if ( display == 'block' ) 58 $(this).fadeOut(2); 59 }); 60 }); 17 61 }); 18 62 19 jQuery('#clearcolor a').click( function(e) { 20 pickColor(''); 21 e.preventDefault(); 22 }); 23 24 jQuery('#background-color').keyup(function() { 25 var _hex = jQuery('#background-color').val(), hex = _hex; 26 if ( hex.charAt(0) != '#' ) 27 hex = '#' + hex; 28 hex = hex.replace(/[^#a-fA-F0-9]+/, ''); 29 if ( hex != _hex ) 30 jQuery('#background-color').val(hex); 31 if ( hex.length == 4 || hex.length == 7 ) 32 pickColor( hex ); 33 }); 34 35 jQuery('input[name="background-position-x"]').change(function() { 36 jQuery('#custom-background-image').css('background-position', jQuery(this).val() + ' top'); 37 }); 38 39 jQuery('input[name="background-repeat"]').change(function() { 40 jQuery('#custom-background-image').css('background-repeat', jQuery(this).val()); 41 }); 42 43 farbtastic = jQuery.farbtastic('#colorPickerDiv', function(color) { 44 pickColor(color); 45 }); 46 pickColor(jQuery('#background-color').val()); 47 48 jQuery(document).mousedown(function(){ 49 jQuery('#colorPickerDiv').each(function(){ 50 var display = jQuery(this).css('display'); 51 if ( display == 'block' ) 52 jQuery(this).fadeOut(2); 53 }); 54 }); 55 }); 63 })(jQuery); -
trunk/wp-includes/theme.php
r20893 r20901 1502 1502 1503 1503 case 'custom-header': 1504 // specific custom header capabilities can be registered by passing 1504 case 'custom-background' : 1505 // specific custom header and background capabilities can be registered by passing 1505 1506 // an array to add_theme_support() 1506 1507 $header_support = $args[0];
Note: See TracChangeset
for help on using the changeset viewer.