PageSourceSearch

https://peter-sapper.de/js/layout.js

js peter-sapper.de collected 2026-10-03 18:41:51 UTC 2,507 bytes, 83 lines download raw bytes

1$(document).ready(function () {
2    var AFFIX_TOP_LIMIT = 300;
3    var AFFIX_OFFSET = 49;
4	$('#menu-left').localScroll({hash:true, onAfterFirst:function(){$('html, body').scrollTo( {top:'-=25px'}, 'fast' );}});
5    var $menu = $("#menu"),
6		$btn = $("#menu-toggle");
7
8    $("#menu-toggle").on("click", function () {
9        $menu.toggleClass("open");
10        return false;
11    });
12
13
14    $(".docs-nav").each(function () {
15        var $affixNav = $(this),
16			$container = $affixNav.parent(),
17			affixNavfixed = false,
18			originalClassName = this.className,
19			current = null,
20			$links = $affixNav.find("a");
21
22        function getClosestHeader(top) {
23            var last = $links.first();
24
25            if (top < AFFIX_TOP_LIMIT) {
26                return last;
27            }
28
29            for (var i = 0; i < $links.length; i++) {
30                var $link = $links.eq(i),
31					href = $link.attr("href");
32
33                if (href.charAt(0) === "#" && href.length > 1) {
34                    var $anchor = $(href).first();
35
36                    if ($anchor.length > 0) {
37                        var offset = $anchor.offset();
38
39                        if (top < offset.top - AFFIX_OFFSET) {
40                            return last;
41                        }
42
43                        last = $link;
44                    }
45                }
46            }
47            return last;
48        }
49
50
51        $(window).on("scroll", function (evt) {
52            var top = window.scrollY,
53		    	height = $affixNav.outerHeight(),
54		    	max_bottom = $container.offset().top + $container.outerHeight(),
55		    	bottom = top + height + AFFIX_OFFSET;
56
57            if (affixNavfixed) {
58                if (top <= AFFIX_TOP_LIMIT) {
59                    $affixNav.removeClass("fixed");
60                    $affixNav.css("top", 0);
61                    affixNavfixed = false;
62                } else if (bottom > max_bottom) {
63                    $affixNav.css("top", (max_bottom - height) - top);
64                } else {
65                    $affixNav.css("top", AFFIX_OFFSET);
66                }
67            } else if (top > AFFIX_TOP_LIMIT) {
68                $affixNav.addClass("fixed");
69                affixNavfixed = true;
70            }
71
72            var $current = getClosestHeader(top);
73
74            if (current !== $current) {
75                $affixNav.find(".active").removeClass("active");
76                $current.addClass("active");
77                current = $current;
78            }
79        });
80    });
81
82    prettyPrint();
83});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.