single.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ( function( $ ) {
  2. var debounce = function( func, wait ) {
  3. var timeout, args, context, timestamp;
  4. return function() {
  5. context = this;
  6. args = [].slice.call( arguments, 0 );
  7. timestamp = new Date();
  8. var later = function() {
  9. var last = ( new Date() ) - timestamp;
  10. if ( last < wait ) {
  11. timeout = setTimeout( later, wait - last );
  12. } else {
  13. timeout = null;
  14. func.apply( context, args );
  15. }
  16. };
  17. if ( ! timeout ) {
  18. timeout = setTimeout( later, wait );
  19. }
  20. };
  21. };
  22. function authorInfo() {
  23. var authorInfo = $( '.author-info' );
  24. if ( authorInfo.length ) {
  25. if ( $( window ).width() > 959 ) {
  26. authorInfo.prependTo( '.widget-area' );
  27. } else {
  28. authorInfo.insertAfter( '.entry-content' );
  29. }
  30. }
  31. }
  32. $( window ).load( authorInfo ).resize( debounce( authorInfo, 500 ) );
  33. $( window ).load( function() {
  34. // Move Sharedaddy & Related Posts
  35. var sharedaddy = $( '.sd-sharing-enabled:not(#jp-post-flair), .sd-like.jetpack-likes-widget-wrapper, .sd-rating' ),
  36. relatedPosts = $( '#jp-relatedposts' );
  37. if ( sharedaddy.length ) {
  38. sharedaddy.appendTo( '.entry-footer' );
  39. }
  40. if ( relatedPosts.length ) {
  41. $( "#jp-post-flair" ).insertAfter( '.entry-footer' );
  42. }
  43. // Make sure tables don't overflow in Entry Content.
  44. $( '.entry-content' ).find( 'table' ).each( function() {
  45. if ( $( this ).width() > $( this ).parent().width() ) {
  46. $( this ).css( 'table-layout', 'fixed' );
  47. }
  48. } );
  49. } );
  50. } )( jQuery );