customizer.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * File 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 a, .site-description' ).css( {
  25. 'clip': 'rect(1px, 1px, 1px, 1px)',
  26. 'position': 'absolute'
  27. } );
  28. } else {
  29. $( '.site-title a, .site-description' ).css( {
  30. 'clip': 'auto',
  31. 'position': 'relative'
  32. } );
  33. $( '.site-title a, .site-description' ).css( {
  34. 'color': to
  35. } );
  36. }
  37. } );
  38. } );
  39. // Changes colours in top of standard post format 'paper'
  40. wp.customize( 'background_color', function( value ) {
  41. value.bind( function( to ) {
  42. if( '' === to ) {
  43. $( 'body:not(.single-post) .format-status span.paper-top' ).css( {
  44. 'background-image': 'linear-gradient(90deg, #bdcbcc 7px, transparent 7px), radial-gradient( #bdcbcc 8px, transparent 8px)'
  45. } );
  46. } else {
  47. $( 'body:not(.single-post) .format-status span.paper-top' ).css( {
  48. 'background-image': 'linear-gradient(90deg, ' + to + ' 7px, transparent 7px), radial-gradient( ' + to + ' 8px, transparent 8px)'
  49. } );
  50. }
  51. } );
  52. } );
  53. } )( jQuery );