customizer.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Theme Customizer enhancements for a better user experience.
  3. *
  4. * Contains handlers to make Theme Customizer preview reload changes asynchronously.
  5. */
  6. ( function( $ ) {
  7. // Site title and description.
  8. wp.customize( 'blogname', function( value ) {
  9. value.bind( function( to ) {
  10. $( '.site-title a' ).text( to );
  11. } );
  12. } );
  13. wp.customize( 'blogdescription', function( value ) {
  14. value.bind( function( to ) {
  15. $( '.site-description' ).text( to );
  16. } );
  17. } );
  18. // Header text color.
  19. wp.customize( 'header_textcolor', function( value ) {
  20. value.bind( function( to ) {
  21. if ( 'blank' === to ) {
  22. $( '.site-title, .site-description' ).css( {
  23. 'clip': 'rect(1px, 1px, 1px, 1px)',
  24. 'position': 'absolute'
  25. } );
  26. } else {
  27. $( '.site-title, .site-description' ).css( {
  28. 'clip': 'auto',
  29. 'color': to,
  30. 'position': 'relative'
  31. } );
  32. }
  33. } );
  34. } );
  35. // Site logo.
  36. wp.customize( 'site_logo', function( value ){
  37. value.bind( function( newVal, oldVal ){
  38. $ (window ).trigger( 'resize' );
  39. } );
  40. } );
  41. // Unfixed header.
  42. wp.customize( 'gazette_unfixed_header', function( value ) {
  43. value.bind( function( to ) {
  44. if ( true === to ) {
  45. $( 'body' ).addClass( 'unfixed-header' );
  46. } else {
  47. $( 'body' ).removeClass( 'unfixed-header' );
  48. }
  49. } );
  50. } );
  51. } )( jQuery );