contact-info-customize-preview.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * File contact-info-area-customize-preview.js.
  3. *
  4. * Allows previewing of the background overlay opacity control.
  5. */
  6. ( function( $ ) {
  7. // Don't show the CTA if everything is empty
  8. $css = '.contact-info-area.contact-info-no-address.contact-info-no-phone.contact-info-no-email.contact-info-no-hours, .contact-info-area.contact-info-footer-display,';
  9. $css += ".contact-info-no-address .contact-info-address,";
  10. $css += ".contact-info-no-phone .contact-info-phone,";
  11. $css += ".contact-info-no-email .contact-info-email,";
  12. $css += ".contact-info-no-hours .contact-info-hours,";
  13. $css += '#masthead .contact-info-area.contact-info-header-no-display,';
  14. $css += '#content + .contact-info-area.contact-info-footer-no-display';
  15. $css += '{ display: none; }'
  16. $( '<style type="text/css">' + $css + '</style>' ).appendTo( 'head' );
  17. // Contact info in Footer or Header toggle
  18. wp.customize( 'radcliffe_2_contact_info_location', function( value ) {
  19. value.bind( function( to ) {
  20. if ( 'header' === to ) {
  21. $( '.contact-info-area' ).addClass( 'contact-info-footer-no-display' ).removeClass( 'contact-info-header-no-display' );
  22. } else {
  23. $( '.contact-info-area' ).addClass( 'contact-info-header-no-display' ).removeClass( 'contact-info-footer-no-display' );
  24. }
  25. } );
  26. } );
  27. // Update the contact info address in real time...
  28. wp.customize( 'site_contact_info[address]', function( value ) {
  29. value.bind( function( to ) {
  30. $( '.contact-info-area .contact-info-address .contact-info-label' ).text( to );
  31. if ( '' === to ) {
  32. $( '.contact-info-area' ).addClass( 'contact-info-no-address' );
  33. $( '.contact-info-area .contact-info-address' ).hide();
  34. } else {
  35. $( '.contact-info-area' ).removeClass( 'contact-info-no-address' );
  36. $( '.contact-info-area .contact-info-address' ).show();
  37. }
  38. } );
  39. } );
  40. // Update the contact info phone in real time...
  41. wp.customize( 'site_contact_info[phone]', function( value ) {
  42. value.bind( function( to ) {
  43. $( '.contact-info-area .contact-info-phone .contact-info-label' ).text( to );
  44. if ( '' === to ) {
  45. $( '.contact-info-area' ).addClass( 'contact-info-no-phone' );
  46. $( '.contact-info-area .contact-info-phone' ).hide();
  47. } else {
  48. $( '.contact-info-area' ).removeClass( 'contact-info-no-phone' );
  49. $( '.contact-info-area .contact-info-phone' ).show();
  50. }
  51. } );
  52. } );
  53. // Update the contact info email in real time...
  54. wp.customize( 'site_contact_info[email]', function( value ) {
  55. value.bind( function( to ) {
  56. $( '.contact-info-area .contact-info-email .contact-info-label' ).text( to );
  57. if ( '' === to ) {
  58. $( '.contact-info-area' ).addClass( 'contact-info-no-email' );
  59. $( '.contact-info-area .contact-info-email' ).hide();
  60. } else {
  61. $( '.contact-info-area' ).removeClass( 'contact-info-no-email' );
  62. $( '.contact-info-area .contact-info-email' ).show();
  63. }
  64. } );
  65. } );
  66. // Update the contact info hours in real time...
  67. wp.customize( 'radcliffe_2_contact_info_hours', function( value ) {
  68. value.bind( function( to ) {
  69. $( '.contact-info-area .contact-info-hours .contact-info-hours-text' ).text( to );
  70. if ( '' === to ) {
  71. $( '.contact-info-area' ).addClass( 'contact-info-no-hours' );
  72. $( '.contact-info-area .contact-info-hours' ).hide();
  73. } else {
  74. $( '.contact-info-area' ).removeClass( 'contact-info-no-hours' );
  75. $( '.contact-info-area .contact-info-hours' ).show();
  76. }
  77. } );
  78. } );
  79. /*
  80. // Update the contact info address in real time...
  81. wp.customize( 'radcliffe_2_contact_info_address', function( value ) {
  82. value.bind( function( newval ) {
  83. $( '.contact-info-address .contact-info-label' ).html( newval );
  84. } );
  85. } );
  86. // Update the contact info phone in real time...
  87. wp.customize( 'radcliffe_2_contact_info_phone', function( value ) {
  88. value.bind( function( newval ) {
  89. $( '.contact-info-phone .contact-info-label' ).html( newval );
  90. } );
  91. } );
  92. // Update the contact info email in real time...
  93. wp.customize( 'radcliffe_2_contact_info_email', function( value ) {
  94. value.bind( function( newval ) {
  95. $( '.contact-info-email .contact-info-label' ).html( newval );
  96. } );
  97. } );
  98. // Update the contact info hours in real time...
  99. wp.customize( 'radcliffe_2_contact_info_hours', function( value ) {
  100. value.bind( function( newval ) {
  101. $( '.contact-info-hours .contact-info-hours-text' ).html( newval );
  102. } );
  103. } );
  104. */
  105. } )( jQuery );