2012-08-02 18:10:03 -04:00
|
|
|
/**
|
|
|
|
* Theme Customizer enhancements for a better user experience.
|
|
|
|
*
|
|
|
|
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
2012-08-27 22:18:43 -04:00
|
|
|
* Things like site title, description, and background color changes.
|
2012-08-02 18:10:03 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
( function( $ ) {
|
|
|
|
// Site title and description.
|
|
|
|
wp.customize( 'blogname', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-02-15 11:53:58 -05:00
|
|
|
$( '.site-title a' ).text( to );
|
2012-08-02 18:10:03 -04:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
wp.customize( 'blogdescription', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-02-15 11:53:58 -05:00
|
|
|
$( '.site-description' ).text( to );
|
2012-08-02 18:10:03 -04:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-15 12:42:10 -04:00
|
|
|
|
2013-03-01 12:45:59 -05:00
|
|
|
// Header text color
|
|
|
|
wp.customize( 'header_textcolor', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-03-15 12:42:10 -04:00
|
|
|
if ( 'blank' === to ) {
|
|
|
|
$( '.site-title, .site-title a, .site-description' ).css( {
|
|
|
|
'clip': 'rect(1px, 1px, 1px, 1px)',
|
|
|
|
'position': 'absolute'
|
|
|
|
} );
|
|
|
|
} else {
|
|
|
|
$( '.site-title, .site-title a, .site-description' ).css( {
|
|
|
|
'clip': 'auto',
|
|
|
|
'color': to,
|
|
|
|
'position': 'relative'
|
|
|
|
} );
|
|
|
|
}
|
2013-03-01 12:45:59 -05:00
|
|
|
} );
|
|
|
|
} );
|
2012-08-02 18:10:03 -04:00
|
|
|
|
2013-03-01 12:14:59 -05:00
|
|
|
// Hook into background color/image change and adjust body class value as needed.
|
2012-07-25 15:42:55 -04:00
|
|
|
wp.customize( 'background_color', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-03-01 12:14:59 -05:00
|
|
|
var body = $( 'body' );
|
|
|
|
|
|
|
|
if ( ( '#ffffff' == to || '#fff' == to ) && 'none' == body.css( 'background-image' ) )
|
|
|
|
body.addClass( 'custom-background-white' );
|
|
|
|
else if ( '' == to && 'none' == body.css( 'background-image' ) )
|
|
|
|
body.addClass( 'custom-background-empty' );
|
2012-07-25 15:42:55 -04:00
|
|
|
else
|
2013-03-01 12:14:59 -05:00
|
|
|
body.removeClass( 'custom-background-empty custom-background-white' );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
wp.customize( 'background_image', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
|
|
|
var body = $( 'body' );
|
|
|
|
|
|
|
|
if ( '' != to )
|
|
|
|
body.removeClass( 'custom-background-empty custom-background-white' );
|
|
|
|
else if ( 'rgb(255, 255, 255)' == body.css( 'background-color' ) )
|
|
|
|
body.addClass( 'custom-background-white' );
|
|
|
|
else if ( 'rgb(230, 230, 230)' == body.css( 'background-color' ) && '' == _wpCustomizeSettings.values.background_color )
|
|
|
|
body.addClass( 'custom-background-empty' );
|
2012-07-25 15:42:55 -04:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-01 12:14:59 -05:00
|
|
|
} )( jQuery );
|