1// ãã³ãã¼ã¬ã¼ã¡ãã¥ã¼ãéãã¦ããã¨ãã«ã¡ã¤ã³ã³ã³ãã³ãã®ã¹ã¯ãã¼ã«ãç¡å¹ã«ãã 2/*document.addEventListener('DOMContentLoaded', function () { 3 let scrollpos = 0; 4 document.querySelectorAll('[name="headmenu"]').forEach(function (elem) { 5 elem.addEventListener('change', function () { 6 if (this.checked) { 7 // ã¹ã¯ãã¼ã«ãç¡å¹ã«ãã 8 scrollpos = window.scrollY || document.documentElement.scrollTop; 9 document.documentElement.classList.add('scroll-prevent'); 10 document.documentElement.style.top = -scrollpos + 'px'; 11 } else { 12 // ã¹ã¯ãã¼ã«ç¡å¹ãè§£é¤ãã 13 document.documentElement.classList.remove('scroll-prevent'); 14 document.documentElement.style.top = '0'; 15 window.scrollTo(0, scrollpos); 16 } 17 }); 18 }); 19});*/ 20 21function matchHeight() { 22 const windowWidth = window.innerWidth; 23 24 // ä¸åº¦é«ãããªã»ãã 25 document.querySelectorAll('[data-mh]').forEach(el => { 26 el.style.height = 'auto'; 27 }); 28 29 // data-mhã®å¤ãã¨ã«ã°ã«ã¼ãåãï¼ãã¤æå¹ãªãã®ã ãï¼ 30 const groups = {}; 31 document.querySelectorAll('[data-mh]').forEach(el => { 32 const group = el.getAttribute('data-mh'); 33 const enableMobile = el.getAttribute('enable-mobile') === 'true'; 34 35 // 896px以ä¸ã§ãã¢ãã¤ã«æªå¯¾å¿ãªãã¹ããã 36 if (windowWidth <= 896 && !enableMobile) return; 37 38 groups[group] = groups[group] || []; 39 groups[group].push(el); 40 }); 41 42 // åã°ã«ã¼ãã§æå¤§ã®é«ããè¨ç®ãã¦æãã 43 for (const key in groups) { 44 const elements = groups[key]; 45 const maxHeight = Math.max(...elements.map(el => el.offsetHeight)); 46 elements.forEach(el => { 47 el.style.height = `${maxHeight}px`; 48 }); 49 } 50} 51 52window.addEventListener('load', matchHeight); 53window.addEventListener('resize', matchHeight); 54 55 56// animation çºç« 57document.addEventListener('DOMContentLoaded', () => { 58 const targets = document.querySelectorAll('[data-animation]');
59 const inView = (el) => { 60 const rect = el.getBoundingClientRect(); 61 return ( 62 rect.top < window.innerHeight && rect.bottom > 0 63 ); 64 }; 65 const animate = () => { 66 targets.forEach(el => { 67 if (inView(el)) { 68 el.classList.add('is-visible'); 69 } else { 70 el.classList.remove('is-visible'); // ä½åº¦ãåºå ¥ãã§ãã 71 } 72 }); 73 }; 74 75 window.addEventListener('scroll', animate); 76 window.addEventListener('resize', animate); 77 animate(); // ååå®è¡ 78}); 79 80// ======================== 81// ã¹ã ã¼ã¹ã¹ã¯ãã¼ã« 82// ======================== 83// ç»é¢åºå®é ç½®ã®ãããã¼ãåå¨ããå ´åããããã¯ãµã¤ãºãåå¾ 84// ã¹ã¯ãã¼ã«æã«ãããã¼é«ããå«ããå ´åãheaderã«data-fixed-headerãè¨è¼ 85const getHeaderBlockSize = function() { 86 const header = document.querySelector("[data-fixed-header]"); 87 if (!header) return 0; 88 89 const computedStyle = window.getComputedStyle(header); 90 const position = computedStyle.position; 91 const blockSize = parseFloat(computedStyle.height); 92 const isFixed = position === "fixed" || position === "sticky"; 93 94 console.log(`Header block size: ${blockSize}px`); // ãããã°ç¨ã«è¿½å 95 return isFixed ? blockSize : 0; 96}; 97 98const scrollToTarget = function(element) { 99 const headerBlockSize = getHeaderBlockSize(); 100 // ã¦ã¼ã¶ã¼ãè¦å·®å¹æãæ¸ããè¨å®ããã¦ãããã©ãããå¤å® 101 const isPrefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches; 102 // è¦å·®å¹æãæ¸ããè¨å®ãããã¦ããå ´å㯠'instant'ãããã§ãªãå ´å㯠'smooth' ã«ã¹ã¯ãã¼ã«åä½ãè¨å® 103 const scrollBehavior = isPrefersReduced ? "instant" : "smooth"; 104 105 const elementTop = element.getBoundingClientRect().top; 106 //const offsetPosition = elementTop + window.scrollY - headerBlockSize - 20; // 20pxä¸ã«ã¹ã¯ãã¼ã«ããããã«ãã 107 const offsetPosition = elementTop + window.scrollY - headerBlockSize + 50; 108 109 window.scrollTo({ 110 top: offsetPosition, 111 behavior: scrollBehavior, 112 }); 113 114 console.log(`Scrolling to element with offset position: ${offsetPosition}px`); // ãããã°ç¨ã«è¿½å 115}; 116 117const focusTarget = function(element) { 118 // ã¿ã¼ã²ããè¦ç´ ã«ãã©ã¼ã«ã¹ãè¨å® 119 element.focus({ preventScroll: true }); 120 // ã¢ã¯ãã£ããªè¦ç´ ãã¿ã¼ã²ããè¦ç´ ã§ãªãå ´å 121 if (document.activeElement !== element) { 122 // ã¿ã¼ã²ããè¦ç´ ã®tabindexã䏿çã«-1ã«è¨å® 123 element.setAttribute("tabindex", "-1"); 124 // å度ãã©ã¼ã«ã¹ãè¨å® 125 element.focus({ preventScroll: true }); 126 // ãã©ã¼ã«ã¹ãå¤ããå¾ãtabindexãå ã«æ»ã 127 element.removeAttribute("tabindex"); 128 } 129}; 130 131const handleClick = function(event) { 132 // ã¯ãªãã¯ããããã¿ã³ãå·¦ãã¿ã³ã§ãªãå ´åã¯å¦çã䏿 133 if (event.button !== 0) return; 134 // ã¯ãªãã¯ããããªã³ã¯è¦ç´ ãåå¾ 135 // ã¯ãªãã¯ãããè¦ç´ ãaè¦ç´ ã¾ãã¯aè¦ç´ ã®åå«ã§ã¯ãªãå ´åã¯å¦çã䏿 136 const currentLink = event.target.closest('a[href*="#"]'); 137 if (!currentLink) return; 138 139 const hash = currentLink.hash; 140 // hashï¼ãªã³ã¯ã®ããã·ã¥é¨åï¼ãåå¨ããªãå ´åã¯å¦çã䏿 141 // ã¯ãªãã¯ãããaè¦ç´ ã®role屿§ãtabã§ããå ´åã¯å¦çã䏿 142 // ã¯ãªãã¯ãããaè¦ç´ ã®role屿§ãbuttonã§ããå ´åã¯å¦çã䏿 143 // ã¯ãªãã¯ãããaè¦ç´ ã«data-smooth-scroll="disabled"ãæå®ããã¦ããå ´åã¯å¦çã䏿 144 if (!hash || 145 currentLink.getAttribute("role") === "tab" || 146 currentLink.getAttribute("role") === "button" || 147 currentLink.getAttribute("data-smooth-scroll") === "disabled") { 148 return; 149 } 150 151 // ã¢ã³ã«ã¼ãªã³ã¯ã®ããã·ã¥é¨åããã¿ã¼ã²ããè¦ç´ ãåå¾ 152 const target = document.getElementById(decodeURIComponent(hash.slice(1))) || (hash === "#top" && document.body); 153 154 if (target) { 155 // ããã©ã«ãã®ãªã³ã¯é·ç§»ã鲿¢ 156 event.preventDefault(); 157 // ã¿ã¼ã²ããè¦ç´ ã¾ã§ã¹ã ã¼ã¹ã«ã¹ã¯ãã¼ã« 158 scrollToTarget(target); 159 // ã¿ã¼ã²ããè¦ç´ ã«ãã©ã¼ã«ã¹ãè¨å® 160 focusTarget(target); 161 // ãã©ã¦ã¶ã®å±¥æ´ã«ã¢ã³ã«ã¼ãªã³ã¯ã®ããã·ã¥ã追å 162 if (!(hash === "#top")) { 163 history.pushState({}, "", hash); 164 } 165 } 166}; 167 168const handleHashOnLoad = function() { 169 const hash = window.location.hash; 170 if (hash) { 171 const target = document.getElementById(decodeURIComponent(hash.slice(1))) || (hash === "#top" && document.body); 172 if (target) { 173 // ã¿ã¼ã²ããè¦ç´ ã¾ã§ã¹ã ã¼ã¹ã«ã¹ã¯ãã¼ã« 174 scrollToTarget(target); 175 // ã¿ã¼ã²ããè¦ç´ ã«ãã©ã¼ã«ã¹ãè¨å® 176 focusTarget(target); 177 } 178 } 179}; 180 181const initializeSmoothScroll = function() { 182 document.addEventListener("click", handleClick, { capture: true });
183 document.addEventListener("DOMContentLoaded", handleHashOnLoad); 184 window.addEventListener("load", handleHashOnLoad); // ãã¼ã¸ãã¼ãå¾ã«ããã·ã¥ãå¦ç 185}; 186 187initializeSmoothScroll(); 188 189// ======================== 190// ç¾å¨ã®ãã¼ã¸ã®ãããã¼å ã¡ãã¥ã¼ã«currentä»ä¸ 191// ======================== 192document.addEventListener('DOMContentLoaded', function () { 193 const links = document.querySelectorAll('.header-menu li a'); 194 const currentPage = location.pathname; 195 196 links.forEach(link => { 197 const href = link.getAttribute('href'); 198 199 // hrefã空ã®å ´åã¯currentãæ¶å» 200 if (!href) { 201 link.parentNode.classList.remove('current'); 202 return; 203 } 204 205 // ãµã¤ãã®TOPãã¼ã¸ã®å ´å 206 if (currentPage === '/index.html' || currentPage === '/') { 207 if (href === '/') { 208 link.parentNode.classList.add('current'); 209 } else { 210 link.parentNode.classList.remove('current'); 211 } 212 // ãã®ä»ã®ãã¼ã¸ã®å ´å 213 } else { 214 // currentPage 㨠href ã®å®å ¨ä¸è´ãç¢ºèª 215 if (currentPage === href || currentPage === href + '/' || currentPage + '/' === href) { 216 link.parentNode.classList.add('current'); 217 } else { 218 link.parentNode.classList.remove('current'); 219 } 220 } 221 }); 222}); 223 224// ======================== 225// ãã¼ã¸ããããã¿ã³ 226// ======================== 227// ä¸ã«ã¹ã¯ãã¼ã«ããã¨ãã ã表示 228const pageTop = document.querySelector('.pagetop'); 229let lastScrollY = window.scrollY; 230window.addEventListener('scroll', () => { 231 const currentScrollY = window.scrollY; 232 const isScrollingUp = currentScrollY < lastScrollY; 233 const isBeyond = currentScrollY > 100; 234 if (isScrollingUp && isBeyond) { 235 pageTop.classList.add('show'); 236 } else { 237 pageTop.classList.remove('show'); 238 } 239 lastScrollY = currentScrollY; 240}); 241pageTop.addEventListener('click', () => { 242 window.scrollTo({ top: 0, behavior: 'smooth' }); 243}); 244 245 246// ã¯ãªãã¯æã«ã¡ãã¥ã¼é表示 247const links = document.querySelectorAll('.global a'); 248links.forEach(link => { 249 link.addEventListener('click', () => { 250 const checkbox = document.getElementById('menu-cb'); 251 if (checkbox) { 252 checkbox.checked = false; 253 } 254 }); 255});
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.