/* CrudeDoc Java Script Copyright (c) 2015 - 2017 Christian Schoenebeck. All rights reserved. http://www.crudebyte.com */ var g_isTouch = false; var g_isMouse = false; function crdWindowWidth() { return window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth; } function crdWindowHeight() { return window.innerHeight || document.documentElement.clientHeight || document.getElementsByTagName('body')[0].clientHeight; } function crdScrollTo(e) { $('html, body').animate({ scrollTop: $( "#" + $(e).attr("section") ).offset().top - 68 }, 300); var obj = $( "#" + $(e).attr("section") ); $(obj).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(120).fadeOut(100).fadeIn(120); } function crdScrollToHash(h) { if (typeof h === 'undefined') { h = location.hash; if (!h || h.length < 2) return; } $('html, body').animate({ scrollTop: $( h ).offset().top - 68 }, 300); $(h).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(120).fadeOut(100).fadeIn(120); } function crdOnScroll() { //var headers = $("body > article :header:in-viewport"); var headers = $("body > article :header"); var wst = $(window).scrollTop(); if (wst <= 0) { for (var i = 0; i < headers.length; ++i) { $("body > aside *[section]").removeClass("current"); var link = $("body > aside *[section='" + headers[i].id + "']"); $(link).addClass("current"); return; } } var wh = crdWindowHeight(); for (var i = headers.length - 1; i >= 0; --i) { var offset = headers[i].offsetTop - wst + wh/2; if (headers[i].id.length > 0 && (offset <= 0 || offset <= wh)) { $("body > aside *[section]").removeClass("current"); var link = $("body > aside *[section='" + headers[i].id + "']"); $(link).addClass("current"); break; } } } 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"); if (typeof(Storage) !== "undefined") { sessionStorage.setItem("show-toc", $("html").hasClass("no-toc") ? "no" : "yes"); } crdUpdateTOCStatus(); } function crdOnWindowResize() { var wh = crdWindowHeight(); $("nav > ul > li ul").css("max-height", wh - 70); } function crdDetectFeatures() { if ('ontouchstart' in document.documentElement) { g_isTouch = true; document.documentElement.className += ' touch'; } else { g_isTouch = false; document.documentElement.className += ' no-touch'; } $(window).bind('mousemove.hasMouse', function(){ $(window).unbind('.hasMouse'); g_isMouse = true; $(document).tooltip(); }).bind('touchstart.hasMouse', function(){ $(window).unbind('.hasMouse'); g_isMouse = false; }); if ($.support["transform"]) { $("body").addClass("hasTransform"); } var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; if (iOS) { $("body").addClass("iOS"); } } $(function() { crdDetectFeatures(); $("article img[caption]").each(function() { $(this).after( "