customizer.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * customizer.js
  3. *
  4. * Theme Customizer enhancements for a better user experience.
  5. *
  6. * Contains handlers to make Theme Customizer preview reload changes asynchronously.
  7. */
  8. ( function( $ ) {
  9. // Site title and description.
  10. wp.customize( 'blogname', function( value ) {
  11. value.bind( function( to ) {
  12. $( '.site-title a' ).text( to );
  13. } );
  14. } );
  15. wp.customize( 'blogdescription', function( value ) {
  16. value.bind( function( to ) {
  17. $( '.site-description' ).text( to );
  18. } );
  19. } );
  20. // Header text color.
  21. wp.customize( 'header_textcolor', function( value ) {
  22. value.bind( function( to ) {
  23. if ( 'blank' === to ) {
  24. $( '.site-title, #tagline' ).css( {
  25. 'clip': 'rect(1px, 1px, 1px, 1px)',
  26. 'position': 'absolute'
  27. } );
  28. } else {
  29. $( '.site-title, #tagline' ).css( {
  30. 'clip': 'auto',
  31. 'position': 'relative'
  32. } );
  33. $( '.site-title a, .site-description' ).css( {
  34. 'color': to
  35. } );
  36. }
  37. } );
  38. } );
  39. // Background image
  40. wp.customize( 'background_image', function( value ) {
  41. value.bind( function( to ) {
  42. var file = to.split(/[\\/]/).pop(); //Get URL's filename to compare with the default
  43. if ( 'toujoursbackground20160105.png' == file ) { //If using the default background image
  44. $( 'body' ).removeClass( 'user-background' );
  45. } else {
  46. $( 'body' ).addClass( 'user-background' );
  47. }
  48. } );
  49. } );
  50. // Background image
  51. wp.customize( 'toujours_featured_image_borders', function( value ) {
  52. value.bind( function( to ) {
  53. if( to === false ) {
  54. $( 'body' ).addClass( 'hide-featured-image-borders' );
  55. } else {
  56. $( 'body' ).removeClass( 'hide-featured-image-borders' );
  57. }
  58. } );
  59. } );
  60. } )( jQuery );