2012-08-03 00:10:03 +02:00
|
|
|
/**
|
2014-10-15 19:21:19 +02:00
|
|
|
* Customizer enhancements for a better user experience.
|
2012-08-03 00:10:03 +02:00
|
|
|
*
|
2014-10-15 19:21:19 +02:00
|
|
|
* Contains handlers to make 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
|
|
|
|
2020-01-29 01:45:18 +01:00
|
|
|
// Header text color.
|
2013-03-01 18:45:59 +01:00
|
|
|
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' );
|
|
|
|
|
2020-05-16 20:42:12 +02:00
|
|
|
if ( ( '#ffffff' === to || '#fff' === to ) && 'none' === body.css( 'background-image' ) )
|
2013-03-01 18:14:59 +01:00
|
|
|
body.addClass( 'custom-background-white' );
|
2020-05-16 20:42:12 +02:00
|
|
|
else if ( '' === to && 'none' === body.css( 'background-image' ) )
|
2013-03-01 18:14:59 +01:00
|
|
|
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' );
|
|
|
|
|
2014-11-20 18:06:23 +01:00
|
|
|
if ( '' !== to ) {
|
2013-03-01 18:14:59 +01:00
|
|
|
body.removeClass( 'custom-background-empty custom-background-white' );
|
2014-11-20 18:06:23 +01:00
|
|
|
} else if ( 'rgb(255, 255, 255)' === body.css( 'background-color' ) ) {
|
2013-03-01 18:14:59 +01:00
|
|
|
body.addClass( 'custom-background-white' );
|
2014-11-20 18:06:23 +01:00
|
|
|
} else if ( 'rgb(230, 230, 230)' === body.css( 'background-color' ) && '' === wp.customize.instance( 'background_color' ).get() ) {
|
2013-03-01 18:14:59 +01:00
|
|
|
body.addClass( 'custom-background-empty' );
|
2014-11-20 18:06:23 +01:00
|
|
|
}
|
2012-07-25 21:42:55 +02:00
|
|
|
} );
|
|
|
|
} );
|
2013-03-01 18:14:59 +01:00
|
|
|
} )( jQuery );
|