Changeset 23568
- Timestamp:
- 03/01/2013 05:14:59 PM (12 years ago)
- Location:
- trunk/wp-content/themes/twentytwelve
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/themes/twentytwelve/functions.php
r23427 r23568 384 384 function twentytwelve_body_class( $classes ) { 385 385 $background_color = get_background_color(); 386 $background_image = get_background_image(); 386 387 387 388 if ( ! is_active_sidebar( 'sidebar-1' ) || is_page_template( 'page-templates/full-width.php' ) ) … … 396 397 } 397 398 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 } 402 405 403 406 // Enable custom font class only if the font CSS is queued to load. … … 446 449 */ 447 450 function twentytwelve_customize_preview_js() { 448 wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '201 20827', true );451 wp_enqueue_script( 'twentytwelve-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20130301', true ); 449 452 } 450 453 add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' ); -
trunk/wp-content/themes/twentytwelve/js/theme-customizer.js
r23429 r23568 19 19 } ); 20 20 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. 22 22 wp.customize( 'background_color', function( value ) { 23 23 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' ); 28 30 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' ); 30 44 } ); 31 45 } );
Note: See TracChangeset
for help on using the changeset viewer.