init.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. jQuery(document).ready(function($) {
  2. $('.nav-toggle').on( 'click', function() {
  3. $( this ).toggleClass( 'active' );
  4. });
  5. $(window).bind("load", function () {
  6. $('#loader').fadeOut(100);
  7. });
  8. var headerHeight = $('.navbar').height();
  9. $(window).on('scroll', { previousTop: 0 },
  10. function() {
  11. var currentTop = $(window).scrollTop();
  12. if (currentTop < this.previousTop) {
  13. if (currentTop > 0 && $('.navbar').hasClass('fixed')) {
  14. $('.navbar').addClass('visible');
  15. } else {
  16. $('.navbar').removeClass('visible fixed');
  17. }
  18. } else {
  19. $('.navbar').removeClass('visible');
  20. if (currentTop > headerHeight && !$('.navbar').hasClass('fixed')) $('.navbar').addClass('fixed');
  21. }
  22. this.previousTop = currentTop;
  23. });
  24. var commentsDiv = $('#comments');
  25. if (commentsDiv.length) {
  26. $(commentsDiv).hide();
  27. $('.toggle-comments').on('click', function(e) {
  28. e.preventDefault();
  29. $(commentsDiv).toggle('slow', function() {
  30. var anchor = $('.toggle-comments');
  31. var anchorText = anchor.text() === 'Hide Comments' ? 'Show Comments' : 'Hide Comments';
  32. $(anchor).text(anchorText);
  33. });
  34. });
  35. }
  36. });