Make WordPress Core

Changeset 23568


Ignore:
Timestamp:
03/01/2013 05:14:59 PM (14 years ago)
Author:
lancewillett
Message:

Twenty Twelve: better handling for cases where a background color is set to white or an empty value (like first run with no theme_mods set) and a background image is enabled, which resulted previously in a broken layout. Fixes #23586, props obenland.

Location:
trunk/wp-content/themes/twentytwelve
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/themes/twentytwelve/functions.php

    r23427 r23568  
    384384function twentytwelve_body_class( $classes ) {
    385385        $background_color = get_background_color();
     386        $background_image = get_background_image();
    386387
    387388        if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) )
     
    396397        }
    397398
    398         if ( empty( $background_color ) )
    399                 $classes[] = 'custom-background-empty';
    400         elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
    401                 $classes[] = 'custom-background-white';
     399        if ( empty( $background_image ) ) {
     400                if ( empty( $background_color ) )
     401                        $classes[] = 'custom-background-empty';
     402                elseif ( in_array( $background_color, array( 'fff', 'ffffff' ) ) )
     403                        $classes[] = 'custom-background-white';
     404        }
    402405
    403406        // Enable custom font class only if the font CSS is queued to load.
     
    446449 */
    447450function twentytwelve_customize_preview_js() {
    448         wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true );
     451        wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20130301', true );
    449452}
    450453add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
  • trunk/wp-content/themes/twentytwelve/js/theme-customizer.js

    r23429 r23568  
    1919        } );
    2020
    21         // Hook into background color change and adjust body class value as needed.
     21        // Hook into background color/image change and adjust body class value as needed.
    2222        wp.customize( 'background_color', function( value ) {
    2323                value.bind( function( to ) {
    24                         if ( '#ffffff' == to || '#fff' == to )
    25                                 $( 'body' ).addClass( 'custom-background-white' );
    26                         else if ( '' == to )
    27                                 $( 'body' ).addClass( 'custom-background-empty' );
     24                        var body = $( 'body' );
     25
     26                        if ( ( '#ffffff' == to || '#fff' == to ) && 'none' == body.css( 'background-image' ) )
     27                                body.addClass( 'custom-background-white' );
     28                        else if ( '' == to && 'none' == body.css( 'background-image' ) )
     29                                body.addClass( 'custom-background-empty' );
    2830                        else
    29                                 $( 'body' ).removeClass( 'custom-background-empty custom-background-white' );
     31                                body.removeClass( 'custom-background-empty custom-background-white' );
     32                } );
     33        } );
     34        wp.customize( 'background_image', function( value ) {
     35                value.bind( function( to ) {
     36                        var body = $( 'body' );
     37
     38                        if ( '' != to )
     39                                body.removeClass( 'custom-background-empty custom-background-white' );
     40                        else if ( 'rgb(255, 255, 255)' == body.css( 'background-color' ) )
     41                                body.addClass( 'custom-background-white' );
     42                        else if ( 'rgb(230, 230, 230)' == body.css( 'background-color' ) && '' == _wpCustomizeSettings.values.background_color )
     43                                body.addClass( 'custom-background-empty' );
    3044                } );
    3145        } );
Note: See TracChangeset for help on using the changeset viewer.