Нема описа

customizer.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /* global blogDisplay, postDetails */
  2. /**
  3. * customizer.js
  4. *
  5. * Theme Customizer enhancements for a better user experience.
  6. *
  7. * Contains handlers to make Theme Customizer preview reload changes asynchronously.
  8. */
  9. ( function ( $ ) {
  10. // Blog Display
  11. wp.customize( 'jetpack_content_blog_display', function ( value ) {
  12. if ( 'content' === blogDisplay.display ) {
  13. $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( {
  14. clip: 'rect(1px, 1px, 1px, 1px)',
  15. position: 'absolute',
  16. } );
  17. $( '.jetpack-blog-display.jetpack-the-content' ).css( {
  18. clip: 'auto',
  19. position: 'relative',
  20. } );
  21. } else if ( 'excerpt' === blogDisplay.display ) {
  22. $( '.jetpack-blog-display.jetpack-the-content' ).css( {
  23. clip: 'rect(1px, 1px, 1px, 1px)',
  24. position: 'absolute',
  25. } );
  26. $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( {
  27. clip: 'auto',
  28. position: 'relative',
  29. } );
  30. } else if ( 'mixed' === blogDisplay.display ) {
  31. $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( {
  32. clip: 'auto',
  33. position: 'relative',
  34. } );
  35. $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( {
  36. clip: 'rect(1px, 1px, 1px, 1px)',
  37. position: 'absolute',
  38. } );
  39. $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( {
  40. clip: 'rect(1px, 1px, 1px, 1px)',
  41. position: 'absolute',
  42. } );
  43. $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( {
  44. clip: 'auto',
  45. position: 'relative',
  46. } );
  47. }
  48. value.bind( function ( to ) {
  49. if ( 'content' === to ) {
  50. $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( {
  51. clip: 'rect(1px, 1px, 1px, 1px)',
  52. position: 'absolute',
  53. } );
  54. $( '.jetpack-blog-display.jetpack-the-content' ).css( {
  55. clip: 'auto',
  56. position: 'relative',
  57. } );
  58. } else if ( 'excerpt' === to ) {
  59. $( '.jetpack-blog-display.jetpack-the-content' ).css( {
  60. clip: 'rect(1px, 1px, 1px, 1px)',
  61. position: 'absolute',
  62. } );
  63. $( '.jetpack-blog-display.jetpack-the-excerpt' ).css( {
  64. clip: 'auto',
  65. position: 'relative',
  66. } );
  67. } else if ( 'mixed' === to ) {
  68. $( '.jetpack-blog-display.jetpack-the-content.output-the-content' ).css( {
  69. clip: 'auto',
  70. position: 'relative',
  71. } );
  72. $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-content' ).css( {
  73. clip: 'rect(1px, 1px, 1px, 1px)',
  74. position: 'absolute',
  75. } );
  76. $( '.jetpack-blog-display.jetpack-the-content.output-the-excerpt' ).css( {
  77. clip: 'rect(1px, 1px, 1px, 1px)',
  78. position: 'absolute',
  79. } );
  80. $( '.jetpack-blog-display.jetpack-the-excerpt.output-the-excerpt' ).css( {
  81. clip: 'auto',
  82. position: 'relative',
  83. } );
  84. }
  85. if ( blogDisplay.masonry ) {
  86. $( blogDisplay.masonry ).masonry();
  87. }
  88. } );
  89. } );
  90. // Post Details: Date.
  91. wp.customize( 'jetpack_content_post_details_date', function ( value ) {
  92. value.bind( function ( to ) {
  93. if ( false === to ) {
  94. $( postDetails.date ).css( {
  95. clip: 'rect(1px, 1px, 1px, 1px)',
  96. height: '1px',
  97. overflow: 'hidden',
  98. position: 'absolute',
  99. width: '1px',
  100. } );
  101. $( 'body' ).addClass( 'date-hidden' );
  102. } else {
  103. $( postDetails.date ).css( {
  104. clip: 'auto',
  105. height: 'auto',
  106. overflow: 'auto',
  107. position: 'relative',
  108. width: 'auto',
  109. } );
  110. $( 'body' ).removeClass( 'date-hidden' );
  111. }
  112. } );
  113. } );
  114. // Post Details: Categories.
  115. wp.customize( 'jetpack_content_post_details_categories', function ( value ) {
  116. value.bind( function ( to ) {
  117. if ( false === to ) {
  118. $( postDetails.categories ).css( {
  119. clip: 'rect(1px, 1px, 1px, 1px)',
  120. height: '1px',
  121. overflow: 'hidden',
  122. position: 'absolute',
  123. width: '1px',
  124. } );
  125. $( 'body' ).addClass( 'categories-hidden' );
  126. } else {
  127. $( postDetails.categories ).css( {
  128. clip: 'auto',
  129. height: 'auto',
  130. overflow: 'auto',
  131. position: 'relative',
  132. width: 'auto',
  133. } );
  134. $( 'body' ).removeClass( 'categories-hidden' );
  135. }
  136. } );
  137. } );
  138. // Post Details: Tags.
  139. wp.customize( 'jetpack_content_post_details_tags', function ( value ) {
  140. value.bind( function ( to ) {
  141. if ( false === to ) {
  142. $( postDetails.tags ).css( {
  143. clip: 'rect(1px, 1px, 1px, 1px)',
  144. height: '1px',
  145. overflow: 'hidden',
  146. position: 'absolute',
  147. width: '1px',
  148. } );
  149. $( 'body' ).addClass( 'tags-hidden' );
  150. } else {
  151. $( postDetails.tags ).css( {
  152. clip: 'auto',
  153. height: 'auto',
  154. overflow: 'auto',
  155. position: 'relative',
  156. width: 'auto',
  157. } );
  158. $( 'body' ).removeClass( 'tags-hidden' );
  159. }
  160. } );
  161. } );
  162. // Post Details: Author.
  163. wp.customize( 'jetpack_content_post_details_author', function ( value ) {
  164. value.bind( function ( to ) {
  165. if ( false === to ) {
  166. $( postDetails.author ).css( {
  167. clip: 'rect(1px, 1px, 1px, 1px)',
  168. height: '1px',
  169. overflow: 'hidden',
  170. position: 'absolute',
  171. width: '1px',
  172. } );
  173. $( 'body' ).addClass( 'author-hidden' );
  174. } else {
  175. $( postDetails.author ).css( {
  176. clip: 'auto',
  177. height: 'auto',
  178. overflow: 'auto',
  179. position: 'relative',
  180. width: 'auto',
  181. } );
  182. $( 'body' ).removeClass( 'author-hidden' );
  183. }
  184. } );
  185. } );
  186. // Post Details: Comment link.
  187. wp.customize( 'jetpack_content_post_details_comment', function ( value ) {
  188. value.bind( function ( to ) {
  189. if ( false === to ) {
  190. $( postDetails.comment ).css( {
  191. clip: 'rect(1px, 1px, 1px, 1px)',
  192. height: '1px',
  193. overflow: 'hidden',
  194. position: 'absolute',
  195. width: '1px',
  196. } );
  197. $( 'body' ).addClass( 'comment-hidden' );
  198. } else {
  199. $( postDetails.comment ).css( {
  200. clip: 'auto',
  201. height: 'auto',
  202. overflow: 'auto',
  203. position: 'relative',
  204. width: 'auto',
  205. } );
  206. $( 'body' ).removeClass( 'comment-hidden' );
  207. }
  208. } );
  209. } );
  210. } )( jQuery );