--- doc/tmpl/js/crd.js 2017/06/02 11:59:21 3269 +++ doc/tmpl/js/crd.js 2017/06/02 18:31:00 3270 @@ -6,6 +6,12 @@ var g_isTouch = false; +function crdWindowWidth() { + return window.innerWidth || + document.documentElement.clientWidth || + document.getElementsByTagName('body')[0].clientWidth; +} + function crdWindowHeight() { return window.innerHeight || document.documentElement.clientHeight || @@ -55,6 +61,21 @@ } } +function crdUpdateTOCStatus() { + var noTOC = $("html").hasClass("no-toc"); + $("nav > .foldbtn a").html( + noTOC ? ">>>" : "<<<" + ); + $("nav > .foldbtn a").attr("title", + noTOC ? "Show content menu." : "Hide content menu." + ) +} + +function crdToggleTOC() { + $("html").toggleClass("no-toc"); + crdUpdateTOCStatus(); +} + function crdOnWindowResize() { var wh = crdWindowHeight(); $("nav > ul > li ul").css("max-height", wh - 70); @@ -84,6 +105,9 @@ $("header a[title]" ).tooltip({ disabled: true }); + $("nav a[title]" ).tooltip({ + disabled: true + }); } $("article img[caption]").each(function() { $(this).after( @@ -114,6 +138,11 @@ }); } }); + var w = crdWindowWidth(); + if (w < 1200) { + $("html").addClass("no-toc"); + } + crdUpdateTOCStatus(); }); $(document).ready(function() {