docs.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Documentation specific JS script
  3. */
  4. $(function () {
  5. var slideToTop = $("<div />");
  6. slideToTop.html('<i class="fa fa-chevron-up"></i>');
  7. slideToTop.css({
  8. position: 'fixed',
  9. bottom: '20px',
  10. right: '25px',
  11. width: '40px',
  12. height: '40px',
  13. color: '#eee',
  14. 'font-size': '',
  15. 'line-height': '40px',
  16. 'text-align': 'center',
  17. 'background-color': '#222d32',
  18. cursor: 'pointer',
  19. 'border-radius': '5px',
  20. 'z-index': '99999',
  21. opacity: '.7',
  22. 'display': 'none'
  23. });
  24. slideToTop.on('mouseenter', function () {
  25. $(this).css('opacity', '1');
  26. });
  27. slideToTop.on('mouseout', function () {
  28. $(this).css('opacity', '.7');
  29. });
  30. $('.wrapper').append(slideToTop);
  31. $(window).scroll(function () {
  32. if ($(window).scrollTop() >= 150) {
  33. if (!$(slideToTop).is(':visible')) {
  34. $(slideToTop).fadeIn(500);
  35. }
  36. } else {
  37. $(slideToTop).fadeOut(500);
  38. }
  39. });
  40. $(slideToTop).click(function () {
  41. $("body").animate({
  42. scrollTop: 0
  43. }, 500);
  44. });
  45. $(".sidebar-menu li a").click(function () {
  46. var $this = $(this);
  47. var target = $this.attr("href");
  48. if (typeof target === 'string') {
  49. $("body").animate({
  50. scrollTop: ($(target).offset().top) + "px"
  51. }, 500);
  52. }
  53. });
  54. });