1/* eslint-disable no-unused-vars */ 2 3 4var defaultThemeMode = "light"; 5var themeMode; 6 7if (document.documentElement) { 8 if (document.documentElement.hasAttribute("data-theme-mode")) { 9 themeMode = document.documentElement.getAttribute("data-theme-mode"); 10 } else { 11 if (localStorage.getItem("data-theme") !== null) { 12 themeMode = localStorage.getItem("data-theme"); 13 } else { 14 themeMode = defaultThemeMode; 15 } 16 } 17 18 if (themeMode === "system") { 19 themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; 20 } 21 22 document.documentElement.setAttribute("data-theme", themeMode); 23} 24 25function toggleThemeMode() { 26 var currentThemeMode = document.documentElement.getAttribute("data-theme"); 27 28 if (currentThemeMode === "dark") { 29 document.documentElement.setAttribute("data-theme", "light"); 30 localStorage.setItem("data-theme", "light"); 31 } else if (currentThemeMode === "light") { 32 document.documentElement.setAttribute("data-theme", "dark"); 33 localStorage.setItem("data-theme", "dark"); 34 } 35} 36 37class Pushbar { 38 constructor(config = { overlay: true, blur: false }) { 39 this.activeId; 40 this.activeElement; 41 this.overlayElement; 42 if (config.overlay) { 43 this.overlayElement = document.createElement('div'); 44 this.overlayElement.classList.add('pushbar_overlay'); 45 document.querySelector('body').appendChild(this.overlayElement); 46 } 47 if (config.blur) { 48 const mainContent = document.querySelector('.pushbar_main_content'); 49 if (mainContent) { 50 mainContent.classList.add('pushbar_blur'); 51 } 52 } 53 this.bindEvents(); 54 } 55 56 emitOpening() { 57 const event = new CustomEvent('pushbar_opening', { bubbles: true, detail: { element: this.activeElement, id: this.activeId } }); 58 this.activeElement.dispatchEvent(event); 59 } 60 61 emitClosing() { 62 const event = new CustomEvent('pushbar_closing', { bubbles: true, detail: { element: this.activeElement, id: this.activeId } }); 63 this.activeElement.dispatchEvent(event); 64 } 65 66 handleOpenEvent(e) { 67 e.preventDefault(); 68 const pushbarId = e.currentTarget.getAttribute('data-pushbar-target'); 69 this.open(pushbarId); 70 } 71 72 handleCloseEvent(e) { 73 e.preventDefault(); 74 this.close(); 75 } 76 77 handleKeyEvent(e) { 78 if (e.keyCode === 27) this.close(); 79 } 80 81 bindEvents() { 82 const triggers = document.querySelectorAll('[data-pushbar-target]'); 83 const closers = document.querySelectorAll('[data-pushbar-close]'); 84 triggers.forEach(trigger => trigger.addEventListener('click', e => this.handleOpenEvent(e), false)); 85 closers.forEach(closer => closer.addEventListener('click', e => this.handleCloseEvent(e), false)); 86 if (this.overlayElement) { 87 this.overlayElement.addEventListener('click', e => this.handleCloseEvent(e), false); 88 } 89 document.addEventListener('keyup', e => this.handleKeyEvent(e)); 90 } 91 92 open(pushbarId) { 93 if (this.activeId === String(pushbarId) || !pushbarId) return; 94 if (this.activeId && this.activeId !== String(pushbarId)) this.close(); 95 this.activeId = pushbarId
96 this.activeElement = document.querySelector(`[data-pushbar-id="${this.activeId}"]`) 97 if (!this.activeElement) return; 98 this.emitOpening(); 99 this.activeElement.classList.add('opened'); 100 const pageRootElement = document.querySelector('html') 101 pageRootElement.classList.add('pushbar_locked'); 102 pageRootElement.setAttribute('pushbar', pushbarId) 103 } 104 105 close() { 106 if (!this.activeId) return; 107 this.emitClosing(); 108 this.activeElement.classList.remove('opened'); 109 const pageRootElement = document.querySelector('html') 110 pageRootElement.classList.remove('pushbar_locked'); 111 pageRootElement.removeAttribute('pushbar') 112 this.activeId = null; 113 this.activeElement = null; 114 } 115} 116 117const pushbar = new Pushbar({ 118 blur: true, 119 overlay: true, 120}); 121 122 123 124 125 126function openSearch() { 127 var search = document.getElementById('searchInline'); 128 var form = document.getElementById('search-form'); 129 search.classList.toggle('open'); 130 if (search.classList.contains('open')) { 131 document.getElementById('search').focus(); 132 } else { 133 form.reset(); 134 } 135} 136 137const searchBtn = document.querySelectorAll('.btn-search'); 138searchBtn.forEach((btn) => { 139 btn.addEventListener('click', openSearch); 140}); 141 142function handleStickyElements() { 143 const elements = document.querySelectorAll('.sticky-element'); 144 145 for (const element of elements) { 146 const stickypostion = document.body.offsetTop + 20; 147 const elementRect = element.getBoundingClientRect(); 148 const scrollTop = window.scrollY; // Get current scroll position 149 150 if (scrollTop >= stickypostion) { 151 // Check if element is larger than required threshold 152 element.classList.add('sticky'); 153 } else { 154 // Element is smaller than threshold, remove sticky regardless 155 element.classList.remove('sticky'); 156 } 157 } 158} 159 160window.addEventListener('scroll', handleStickyElements); 161 162// Call the function initially 163handleStickyElements();
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.