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