base.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. $(document).ready(function ()
  2. {
  3. // Tipue Search activation
  4. $('#tipue_search_input').tipuesearch({
  5. 'mode': 'json',
  6. 'contentLocation': '/search_content.json'
  7. });
  8. prettyPrint();
  9. // Resizing
  10. resizeMenuDropdown();
  11. checkToScrollTOC();
  12. $(window).resize(function() {
  13. if(this.resizeTO)
  14. {
  15. clearTimeout(this.resizeTO);
  16. }
  17. this.resizeTO = setTimeout(function ()
  18. {
  19. resizeMenuDropdown();
  20. checkToScrollTOC();
  21. }, 500);
  22. });
  23. /* Auto scroll */
  24. $('#nav_menu').scrollToFixed({
  25. dontSetWidth: true,
  26. });
  27. /* Toggle TOC view for Mobile */
  28. $('#toc_table').on('click', function ()
  29. {
  30. if ( $(window).width() <= 991 )
  31. {
  32. $('#toc_table > #toc_navigation').slideToggle();
  33. }
  34. })
  35. /* Follow TOC links (ScrollSpy) */
  36. $('body').scrollspy({
  37. target: '#toc_table',
  38. });
  39. /* Prevent disabled link clicks */
  40. $("li.disabled a").click(function ()
  41. {
  42. event.preventDefault();
  43. });
  44. });
  45. function resizeMenuDropdown ()
  46. {
  47. $('.dd_menu > .dd_submenu').css("max-height", ($('body').height() - 160) + 'px');
  48. }
  49. // https://github.com/bigspotteddog/ScrollToFixed
  50. function checkToScrollTOC ()
  51. {
  52. if ( $(window).width() >= 768 )
  53. {
  54. if ( ($('#toc_table').height() + 100) >= $(window).height() )
  55. {
  56. $('#toc_table').trigger('detach.ScrollToFixed');
  57. $('#toc_navigation > li.active').removeClass('active');
  58. }
  59. else
  60. {
  61. $('#toc_table').scrollToFixed({
  62. marginTop: $('#nav_menu').height() + 14,
  63. limit: function () { return $('#footer').offset().top - 450; },
  64. zIndex: 1,
  65. minWidth: 768,
  66. removeOffsets: true,
  67. });
  68. }
  69. }
  70. }