2012-08-03 00:10:03 +02:00
|
|
|
/**
|
|
|
|
* Theme Customizer enhancements for a better user experience.
|
|
|
|
*
|
|
|
|
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
2012-08-28 04:18:43 +02:00
|
|
|
* Things like site title, description, and background color changes.
|
2012-08-03 00:10:03 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
( function( $ ) {
|
|
|
|
// Site title and description.
|
|
|
|
wp.customize( 'blogname', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-02-15 17:53:58 +01:00
|
|
|
$( '.site-title a' ).text( to );
|
2012-08-03 00:10:03 +02:00
|
|
|
} );
|
|
|
|
} );
|
|
|
|
wp.customize( 'blogdescription', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-02-15 17:53:58 +01:00
|
|
|
$( '.site-description' ).text( to );
|
2012-08-03 00:10:03 +02:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-15 17:42:10 +01:00
|
|
|
|
2013-03-01 18:45:59 +01:00
|
|
|
// Header text color
|
|
|
|
wp.customize( 'header_textcolor', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-03-15 17:42:10 +01: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 18:45:59 +01:00
|
|
|
} );
|
|
|
|
} );
|
2012-08-03 00:10:03 +02:00
|
|
|
|
2013-03-01 18:14:59 +01:00
|
|
|
// Hook into background color/image change and adjust body class value as needed.
|
2012-07-25 21:42:55 +02:00
|
|
|
wp.customize( 'background_color', function( value ) {
|
|
|
|
value.bind( function( to ) {
|
2013-03-01 18:14:59 +01: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 21:42:55 +02:00
|
|
|
else
|
2013-03-01 18:14:59 +01: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 21:42:55 +02:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-01 18:14:59 +01:00
|
|
|
} )( jQuery );
|