customizer.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if( '' === to ) {
  19. $( 'body' ).removeClass( 'has-description' );
  20. } else {
  21. $( 'body' ).addClass( 'has-description' );
  22. }
  23. } );
  24. } );
  25. wp.customize( 'ixion_button_text', function( value ) {
  26. value.bind( function( to ) {
  27. $( '.callout-button' ).text( to );
  28. if( '' === to ) {
  29. $( 'body' ).removeClass( 'has-cta-button' );
  30. } else {
  31. $( 'body' ).addClass( 'has-cta-button' );
  32. }
  33. } );
  34. } );
  35. // Header text color.
  36. wp.customize( 'header_textcolor', function( value ) {
  37. value.bind( function( to ) {
  38. if ( 'blank' === to ) {
  39. $( '.site-title a, .site-description' ).css( {
  40. 'clip': 'rect(1px, 1px, 1px, 1px)',
  41. 'position': 'absolute'
  42. } );
  43. $( 'body' ).addClass( 'header-text-hidden' );
  44. } else {
  45. $( '.site-title a, .site-description' ).css( {
  46. 'clip': 'auto',
  47. 'position': 'relative'
  48. } );
  49. $( '.site-title a' ).css( {
  50. 'color': to
  51. } );
  52. $( 'body' ).removeClass( 'header-text-hidden' );
  53. }
  54. } );
  55. } );
  56. // Header Image Opacity
  57. wp.customize( 'ixion_header_overlay_opacity', function( value ) {
  58. value.bind( function( to ) {
  59. $( 'body' ).removeClass( 'header-overlay-none header-overlay-light header-overlay-medium' );
  60. if ( 'none' === to ) {
  61. $( 'body' ).addClass( 'header-overlay-none' );
  62. } else if ( 'light' === to ) {
  63. $( 'body' ).addClass( 'header-overlay-light' );
  64. } else if ( 'medium' === to ) {
  65. $( 'body' ).addClass( 'header-overlay-medium' );
  66. }
  67. } );
  68. } );
  69. // Featured Content Opacity
  70. wp.customize( 'ixion_featured_overlay_opacity', function( value ) {
  71. value.bind( function( to ) {
  72. $( 'body' ).removeClass( 'featured-content-overlay-none featured-content-overlay-light featured-content-overlay-dark' );
  73. if ( 'none' === to ) {
  74. $( 'body' ).addClass( 'featured-content-overlay-none' );
  75. } else if ( 'light' === to ) {
  76. $( 'body' ).addClass( 'featured-content-overlay-light' );
  77. } else if ( 'dark' === to ) {
  78. $( 'body' ).addClass( 'featured-content-overlay-dark' );
  79. }
  80. } );
  81. } );
  82. } )( jQuery );