functions.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Theme functions file.
  3. *
  4. * Contains handlers for navigation and widget area.
  5. */
  6. ( function( $ ) {
  7. var $body = $( document.body ),
  8. $window = $( window ),
  9. mastheadHeight = $( '#masthead' ).outerHeight( true ),
  10. coverImage = $( '.home.page .entry-content > .wp-block-cover' ),
  11. entryHeaderHeight = $body.is( '.hide-homepage-title' ) ? 0 : $( '.home.page .entry > .entry-header' ).outerHeight( true ),
  12. coverImageHeight = coverImage.height(),
  13. windowWidth = window.innerWidth,
  14. toolbarHeight,
  15. resizeTimer;
  16. // Make Featured image full-screen.
  17. function fullscreenCoverImage() {
  18. if ( ! coverImage ) {
  19. return;
  20. }
  21. toolbarHeight = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
  22. coverImage.css( {
  23. 'height': $window.height() - ( toolbarHeight + mastheadHeight + entryHeaderHeight ) + 'px'
  24. } );
  25. }
  26. $( document ).ready( function() {
  27. $window.on( 'resize.sophisticatedbusiness', function() {
  28. windowWidth = window.innerWidth;
  29. clearTimeout( resizeTimer );
  30. resizeTimer = setTimeout( function() {
  31. fullscreenCoverImage();
  32. }, 300 );
  33. } );
  34. fullscreenCoverImage();
  35. } );
  36. } )( jQuery );