PageSourceSearch

https://lehrer-werden-in-sachsen.de/wp-content/themes/22-piok-025/assets/js/hide-show-header.js?ver=1.0.0

js lehrer-werden-in-sachsen.de collected 2026-10-04 14:19:24 UTC 3,789 bytes, 109 lines download raw bytes

1var w = document.documentElement.clientWidth || window.innerWidth;
2if (w > 1024) {
3  ("use strict");
4  OB_ready(OB_doWhenReady);
5
6  function OB_doWhenReady() {
7    // localize everything
8    var ooohBoi = window.ooohBoi || {};
9    // local scope variables
10    ooohBoi.prev_scroll_pos = window.scrollY || document.body.scrollTop;
11    ooohBoi.cur_scroll_pos;
12    ooohBoi.scroll_direction = "init";
13    ooohBoi.prev_scroll_direction = 0;
14    ooohBoi.header = document.querySelector("#show-hide-header"); // header ID
15    ooohBoi.header_pos = {
16      top: ooohBoi.header.offsetTop,
17      left: ooohBoi.header.offsetLeft,
18    };
19    ooohBoi.header_height = OB_outerHeight(ooohBoi.header);
20    // show-hide header with ease/transition
21    ooohBoi.header.style.transition = "all 0.3s ease";
22    // update header height on window resize
23    ooohBoi.updateHeaderHeight = function () {
24      ooohBoi.header_height = OB_outerHeight(ooohBoi.header);
25    };
26    // listen "scroll" event and decide what to do
27    ooohBoi.checkScroll = function () {
28      ooohBoi.cur_scroll_pos = window.scrollY || document.body.scrollTop;
29
30      if (ooohBoi.cur_scroll_pos > ooohBoi.prev_scroll_pos)
31        ooohBoi.scroll_direction = "down";
32      else if (ooohBoi.cur_scroll_pos < ooohBoi.prev_scroll_pos)
33        ooohBoi.scroll_direction = "up";
34
35      if (ooohBoi.scroll_direction !== ooohBoi.prev_scroll_direction)
36        ooohBoi.toggleHeader(ooohBoi.scroll_direction, ooohBoi.cur_scroll_pos);
37      ooohBoi.prev_scroll_pos = ooohBoi.cur_scroll_pos;
38    };
39    // add or remove class based on the scrolling direction
40    ooohBoi.toggleHeader = function (scroll_direction, scroll_current) {
41      if (
42        scroll_direction === "down" &&
43        scroll_current > ooohBoi.header_height
44      ) {
45        OB_addClass(ooohBoi.header, "im-hidden"); // for styling
46        ooohBoi.header.style.top = -1 * (ooohBoi.header_height + 50) + "px";
47        ooohBoi.prev_scroll_direction = scroll_direction;
48      } else if (scroll_direction === "up") {
49        OB_removeClass(ooohBoi.header, "im-hidden");
50        ooohBoi.header.style.top = ooohBoi.header_pos.top + "px";
51        ooohBoi.prev_scroll_direction = scroll_direction;
52      }
53    };
54    // listen "scroll" and "resize" window events
55    window.addEventListener("scroll", ooohBoi.checkScroll);
56    window.addEventListener("resize", ooohBoi.updateHeaderHeight);
57  }
58
59  function OB_outerHeight(el) {
60    var height = el.offsetHeight;
61    var style = getComputedStyle(el);
62    height += parseInt(style.marginTop) + parseInt(style.marginBottom);
63    return height;
64  }
65
66  function OB_addClass(el, className) {
67    if (el.classList) el.classList.add(className);
68    else {
69      var current = el.className,
70        found = false;
71      var all = current.split(" ");
72      for (var i = 0; i < all.length, !found; i++) found = all[i] === className;
73      if (!found) {
74        if (current === "") el.className = className;
75        else el.className += " " + className;
76      }
77    }
78  }
79
80  function OB_removeClass(el, className) {
81    if (el.classList) el.classList.remove(className);
82    else
83      el.className = el.className.replace(
84        new RegExp(
85          "(^|\\b)" + className.split(" ").join("|") + "(\\b|$)",
86          "gi"
87        ),
88        " "
89      );
90  }
91
92  function OB_ready(fn) {
93    if (document.readyState != "loading") fn();
94    else if (document.addEventListener)
95      document.addEventListener("DOMContentLoaded", fn);
96    else {
97      document.attachEvent("onreadystatechange", function () {
98        if (document.readyState != "loading") fn();
99      });
100    }
101  }
102}
103
104const navigationHeigth =
105  document.querySelector("#show-hide-header").offsetHeight;
106document.documentElement.style.setProperty(
107  "--scroll-padding",
108  navigationHeigth
109);

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.