Theme Customizer: Correctly use custom-background class in theme preview. See #19910.

git-svn-id: https://develop.svn.wordpress.org/trunk@20919 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith 2012-05-25 22:43:11 +00:00
parent e0fc4ce778
commit b756f8b246
1 changed files with 15 additions and 2 deletions

View File

@ -81,15 +81,28 @@
}); });
api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) { api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) {
var style = $('#custom-background-css'), var body = $(document.body),
style = $('#custom-background-css'),
update; update;
if ( ! style.length ) // If custom backgrounds are active and we can't find the
// default output, bail.
if ( body.hasClass('custom-background') && ! style.length )
return; return;
// Create the CSS container if it doesn't already exist.
if ( ! style.length )
style = $('<style type="text/css" id="custom-background-css" />').appendTo('head');
update = function() { update = function() {
var css = ''; var css = '';
// The body will support custom backgrounds if either
// the color or image are set.
//
// See get_body_class() in /wp-includes/post-template.php
body.toggleClass( 'custom-background', !! ( color() || image() ) );
if ( color() ) if ( color() )
css += 'background-color: #' + color() + ';'; css += 'background-color: #' + color() + ';';