customizer.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. // Display/hide post titles
  36. wp.customize( 'spun_titles', function( value ) {
  37. value.bind( function( to ) {
  38. if ( false === to ) {
  39. $( '.hentry .thumbnail-title' ).css( {
  40. 'display': 'none',
  41. } );
  42. $( '.hentry.no-thumbnail .thumbnail-title' ).css( {
  43. 'display': 'block',
  44. } );
  45. } else {
  46. $( '.hentry .thumbnail-title' ).css( {
  47. 'display': 'block',
  48. } );
  49. }
  50. } );
  51. } );
  52. // Color circles
  53. wp.customize( 'spun_grayscale', function( value ) {
  54. value.bind( function( to ) {
  55. if ( false === to ) {
  56. $( '.blog .hentry a .attachment-home-post,'+
  57. '.archive .hentry a .attachment-home-post,'+
  58. '.search .hentry a .attachment-home-post' ).css( {
  59. 'filter': 'grayscale(100%)',
  60. '-webkit-filter': 'grayscale(100%)',
  61. '-webkit-filter': 'grayscale(1)',
  62. '-moz-filter': 'grayscale(100%)',
  63. '-o-filter': 'grayscale(100%)',
  64. '-ms-filter': 'grayscale(100%)',
  65. 'filter': 'gray',
  66. 'filter': 'filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale")'
  67. } );
  68. } else {
  69. $( '.blog .hentry a .attachment-home-post,'+
  70. '.archive .hentry a .attachment-home-post,'+
  71. '.search .hentry a .attachment-home-post' ).css( {
  72. 'filter': 'grayscale(0)',
  73. '-webkit-filter': 'grayscale(0)',
  74. '-moz-filter': 'grayscale(0)',
  75. '-o-filter': 'grayscale(0)',
  76. '-ms-filter': 'grayscale(0)',
  77. } );
  78. }
  79. } );
  80. } );
  81. // Opacity
  82. /*
  83. wp.customize( 'spun_opacity', function( value ) {
  84. value.bind( function( to ) {
  85. if ( false === to ) {
  86. $( '.site-content #nav-below .nav-previous a,'+
  87. '.site-content #nav-below .nav-next a,'+
  88. '.site-content #image-navigation .nav-previous a,'+
  89. '.site-content #image-navigation .nav-next a,'+
  90. '.comment-navigation .nav-next,'+
  91. '.comment-navigation .nav-previous,'+
  92. '#infinite-handle span,'+
  93. '.sidebar-link,'+
  94. 'a.comment-reply-link,'+
  95. 'a#cancel-comment-reply-link,'+
  96. '.comments-link a,'+
  97. '.hentry.no-thumbnail,'+
  98. 'button,'+
  99. 'html input[type="button"],'+
  100. 'input[type="reset"],'+
  101. 'input[type="submit"],'+
  102. '.site-footer' ).css( {
  103. 'opacity': '.2',
  104. } );
  105. $( '.site-header,'+
  106. '.entry-meta-wrapper,'+
  107. '.comment-meta,'+
  108. '.page-links span.active-link,'+
  109. '.page-links a span.active-link' ).css( {
  110. 'opacity': '.3',
  111. } );
  112. } else {
  113. $( '.site-header,'+
  114. '.site-footer,'+
  115. '.entry-meta-wrapper,'+
  116. '.comment-meta,'+
  117. '.hentry.no-thumbnail,'+
  118. '.site-content #nav-below .nav-previous a,'+
  119. '.site-content #nav-below .nav-next a,'+
  120. '.site-content #image-navigation .nav-previous a,'+
  121. '.site-content #image-navigation .nav-next a,'+
  122. '.comment-navigation .nav-next,'+
  123. '.comment-navigation .nav-previous,'+
  124. '#infinite-handle span,'+
  125. '.sidebar-link,'+
  126. 'a.comment-reply-link,'+
  127. 'a#cancel-comment-reply-link,'+
  128. '.comments-link a,'+
  129. 'button,'+
  130. 'html input[type="button"],'+
  131. 'input[type="reset"],'+
  132. 'input[type="submit"],'+
  133. '.page-links span.active-link,'+
  134. '.page-links a span.active-link' ).css( {
  135. 'opacity': '1',
  136. } );
  137. }
  138. } );
  139. } );
  140. */
  141. } )( jQuery );