github.com/feiyang21687/docker@v1.5.0/docs/theme/mkdocs/js/base.js (about) 1 $(document).ready(function () 2 { 3 4 prettyPrint(); 5 6 // Resizing 7 resizeMenuDropdown(); 8 // checkToScrollTOC(); 9 $(window).resize(function() { 10 if(this.resizeTO) 11 { 12 clearTimeout(this.resizeTO); 13 } 14 this.resizeTO = setTimeout(function () 15 { 16 resizeMenuDropdown(); 17 // checkToScrollTOC(); 18 }, 500); 19 }); 20 21 /* Follow TOC links (ScrollSpy) */ 22 $('body').scrollspy({ 23 target: '#toc_table', 24 }); 25 26 /* Prevent disabled link clicks */ 27 $("li.disabled a").click(function () 28 { 29 event.preventDefault(); 30 }); 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 getURLP(name) 49 { 50 return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null; 51 } 52 if (getURLP("q")) { 53 // Tipue Search activation 54 $('#tipue_search_input').tipuesearch({ 55 'mode': 'json', 56 'contentLocation': '/search_content.json.gz' 57 }); 58 } 59 60 }); 61 62 function resizeMenuDropdown () 63 { 64 $('.dd_menu > .dd_submenu').css("max-height", ($('body').height() - 160) + 'px'); 65 } 66 67 // https://github.com/bigspotteddog/ScrollToFixed 68 function checkToScrollTOC () 69 { 70 if ( $(window).width() >= 768 ) 71 { 72 // If TOC is hidden, expand. 73 $('#toc_table > #toc_navigation').css("display", "block"); 74 // Then attach or detach fixed-scroll 75 if ( ($('#toc_table').height() + 100) >= $(window).height() ) 76 { 77 $('#toc_table').trigger('detach.ScrollToFixed'); 78 $('#toc_navigation > li.active').removeClass('active'); 79 } 80 else 81 { 82 $('#toc_table').scrollToFixed({ 83 marginTop: $('#nav_menu').height(), 84 limit: function () { return $('#footer').offset().top - 450; }, 85 zIndex: 1, 86 minWidth: 768, 87 removeOffsets: true, 88 }); 89 } 90 } 91 } 92 93 function getCookie(cname) { 94 var name = cname + "="; 95 var ca = document.cookie.split(';'); 96 for(var i=0; i<ca.length; i++) { 97 var c = ca[i].trim(); 98 if (c.indexOf(name) == 0) return c.substring(name.length,c.length); 99 } 100 return ""; 101 }