style.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*!
  2. * Theme for Simplify blog
  3. * vuquangtrong.github.io
  4. */
  5. /* function to add line number into codeblock */
  6. /*
  7. (function() {
  8. var pre = document.getElementsByTagName('pre'),
  9. pl = pre.length;
  10. for (var i = 0; i < pl; i++) {
  11. pre[i].innerHTML = '<span class="line-number"></span>' + pre[i].innerHTML + '<span class="cl"></span>';
  12. var num = pre[i].innerHTML.split(/\n/).length;
  13. for (var j = 0; j < (num - 1); j++) {
  14. var line_num = pre[i].getElementsByTagName('span')[0];
  15. line_num.innerHTML += '<span>' + (j + 1) + '</span>';
  16. }
  17. }
  18. })();
  19. */
  20. /* force to hide expanded navbar when scroll down */
  21. $(window).scroll(function(e) {
  22. var scroll = $(window).scrollTop();
  23. if (scroll >= 150) {
  24. $('#navbarMenu').collapse('hide');
  25. }
  26. if (scroll >= 300) {
  27. $('#backToTop').fadeIn();
  28. } else {
  29. $('#backToTop').fadeOut();
  30. }
  31. });
  32. /* add classes into tables */
  33. $("table:not(.highlighttable)").addClass("table table-hover table-sm table-bordered");
  34. $("thead").addClass("thead-light");
  35. /* add classes into images */
  36. $("img").addClass("img-fluid mx-auto shadow-lg");
  37. /* action to back to top */
  38. $('#backToTop').click(function() {
  39. $("html, body").animate({ scrollTop: 0 }, 600);
  40. return false;
  41. });