PageSourceSearch

https://www.landhaus-beckmann.de/wp-content/themes/OPENSMJLE/assets/js/opensmjle.ui.js?ver=1.21790836932

js landhaus-beckmann.de collected 2026-10-01 06:43:09 UTC 4,344 bytes, 146 lines download raw bytes

1// Sticky Header & Headline Bar Scroll Behavior
2function handleStickyScroll() {
3  const body = document.body;
4  if (window.scrollY > 50) {
5    body.classList.add('isSticky');
6  } else {
7    body.classList.remove('isSticky');
8  }
9}
10
11// Headline Message bar
12function initHeadlineBar() {
13  const body = document.body;
14  const closeBtn = document.getElementById('close-headline-bar');
15  const bar = document.getElementById('top-headline-bar');
16
17  if (!bar) return;
18
19  const closedAt = localStorage.getItem('headlineBarClosedAt');
20  const now = new Date().getTime();
21
22  if (closedAt && now - parseInt(closedAt, 10) < 30 * 60 * 1000) {
23    bar.remove();
24  } else {
25    bar.classList.remove('hidden');
26    body.classList.add('headline-show');
27  }
28
29  if (closeBtn) {
30    closeBtn.addEventListener('click', function () {
31      bar.remove();
32      body.classList.remove('headline-show');
33      localStorage.setItem('headlineBarClosedAt', new Date().getTime().toString());
34    });
35  }
36}
37
38// Layover Menu Toggle Script
39function initMenuToggle() {
40  const menuToggle = document.getElementById('menu-toggle');
41  const layover = document.getElementById('menu-layover');
42  const mainHeader = document.getElementById('mainheader');
43
44  if (!menuToggle || !layover) {
45    console.warn('menu-toggle or menu-layover not found');
46    return;
47  }
48
49  menuToggle.addEventListener('click', function () {
50    this.classList.toggle('open');
51    layover.classList.toggle('active');
52    if (mainHeader) {
53      mainHeader.classList.toggle('open');
54    }
55  });
56}
57
58// Header Search functionality
59function initHeaderSearch() {
60  const toggleBtn = document.querySelector('.js-toggle-search');
61  const panel = document.getElementById('header-search-form');
62
63  if (!toggleBtn) { console.warn('[Header Search] Toggle button not found'); return; }
64  if (!panel)     { console.warn('[Header Search] Panel #header-search-form not found'); return; }
65
66  if (!toggleBtn.getAttribute('aria-controls')) {
67    toggleBtn.setAttribute('aria-controls', 'header-search-form');
68  }
69  toggleBtn.setAttribute('aria-expanded', 'false');
70  panel.hidden = true;
71
72  const openPanel = () => {
73    toggleBtn.setAttribute('aria-expanded', 'true');
74    panel.hidden = false;
75    const input = panel.querySelector('.os-search-input');
76    if (input) input.focus();
77  };
78  
79  const closePanel = () => {
80    toggleBtn.setAttribute('aria-expanded', 'false');
81    panel.hidden = true;
82  };
83
84  toggleBtn.addEventListener('click', function () {
85    const isOpen = toggleBtn.getAttribute('aria-expanded') === 'true';
86    isOpen ? closePanel() : openPanel();
87  });
88
89  document.addEventListener('keydown', function (e) {
90    if (e.key === 'Escape' && !panel.hidden) closePanel();
91  });
92  
93  document.addEventListener('click', function (e) {
94    if (panel.hidden) return;
95    const within = panel.contains(e.target) || toggleBtn.contains(e.target);
96    if (!within) closePanel();
97  });
98}
99
100// WPForms Datepicker Activation
101function initWPFormsDatepicker() {
102  jQuery(document).on('wpformsReady', function () {
103    jQuery('.date-picker input').each(function () {
104      jQuery(this).datepicker({
105        dateFormat: 'dd/mm/yy'
106      });
107    });
108  });
109}
110
111// Close handlers (ESC key for menu and search)
112function initGlobalCloseHandlers() {
113  document.addEventListener('keydown', function (e) {
114    if (e.key === 'Escape' || e.key === 'Esc') {
115      // Close menu
116      const layover = document.getElementById('menu-layover');
117      const menuToggle = document.getElementById('menu-toggle');
118      const mainHeader = document.getElementById('mainheader');
119      
120      if (layover && layover.classList.contains('active')) {
121        layover.classList.remove('active');
122        if (menuToggle) menuToggle.classList.remove('open');
123        if (mainHeader) mainHeader.classList.remove('open');
124      }
125      
126      // Close search (handled separately in initHeaderSearch)
127    }
128  });
129}
130
131// Main initialization
132document.addEventListener('DOMContentLoaded', function () {
133  // Scroll event (shared by sticky header and headline bar)
134  window.addEventListener('scroll', handleStickyScroll);
135  
136  // Initialize all components
137  initHeadlineBar();
138  initMenuToggle();
139  initHeaderSearch();
140  initGlobalCloseHandlers();
141});
142
143// WPForms initialization (jQuery based)
144if (typeof jQuery !== 'undefined') {
145  initWPFormsDatepicker();
146}

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.