base.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /* Follow TOC links (ScrollSpy) */
  24. $('body').scrollspy({
  25. target: '#toc_table',
  26. });
  27. /* Prevent disabled link clicks */
  28. $("li.disabled a").click(function ()
  29. {
  30. event.preventDefault();
  31. });
  32. // Submenu ensured drop-down functionality for desktops & mobiles
  33. $('.dd_menu').on({
  34. click: function ()
  35. {
  36. $(this).toggleClass('dd_on_hover');
  37. },
  38. mouseenter: function ()
  39. {
  40. $(this).addClass('dd_on_hover');
  41. },
  42. mouseleave: function ()
  43. {
  44. $(this).removeClass('dd_on_hover');
  45. },
  46. });
  47. });
  48. function resizeMenuDropdown ()
  49. {
  50. $('.dd_menu > .dd_submenu').css("max-height", ($('body').height() - 160) + 'px');
  51. }
  52. // https://github.com/bigspotteddog/ScrollToFixed
  53. function checkToScrollTOC ()
  54. {
  55. if ( $(window).width() >= 768 )
  56. {
  57. // If TOC is hidden, expand.
  58. $('#toc_table > #toc_navigation').css("display", "block");
  59. // Then attach or detach fixed-scroll
  60. if ( ($('#toc_table').height() + 100) >= $(window).height() )
  61. {
  62. $('#toc_table').trigger('detach.ScrollToFixed');
  63. $('#toc_navigation > li.active').removeClass('active');
  64. }
  65. else
  66. {
  67. $('#toc_table').scrollToFixed({
  68. marginTop: $('#nav_menu').height(),
  69. limit: function () { return $('#footer').offset().top - 450; },
  70. zIndex: 1,
  71. minWidth: 768,
  72. removeOffsets: true,
  73. });
  74. }
  75. }
  76. }
  77. function getCookie(cname) {
  78. var name = cname + "=";
  79. var ca = document.cookie.split(';');
  80. for(var i=0; i<ca.length; i++) {
  81. var c = ca[i].trim();
  82. if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
  83. }
  84. return "";
  85. }