1export class TOC { 2 constructor(rootElement, handler, content) { 3 this.rootElement = rootElement 4 this.handler = handler 5 this.content = content 6 this.updateMaxHeight() 7 8 this.appendButton() 9 this.attachEvents() 10 } 11 12 /** 13 * tocãéãéãmax-heightã®å¤ãé«ãããã¨ã¢ãã¡ã¼ã·ã§ã³ã®è¦è¦çãªdurationãé«ãããããé©å®å¤æ´ãã 14 */ 15 updateMaxHeight() { 16 this.maxHeight = this.content.scrollHeight 17 this.content.style.setProperty('--max-height', `${this.maxHeight}px`) 18 } 19 20 attachEvents() { 21 const handlers = [this.button, this.handler] 22 handlers.forEach((handler) => { 23 handler.addEventListener('click', () => { 24 if (this.rootElement.classList.contains('open')) { 25 this.rootElement.classList.remove('open') 26 } else { 27 this.rootElement.classList.add('open') 28 } 29 }) 30 }) 31 32 window.addEventListener('resize', () => { 33 this.updateMaxHeight() 34 }) 35 } 36 37 appendButton() { 38 const buttonElement = document.createElement('button'); 39 buttonElement.classList.add('toc_button'); 40 buttonElement.textContent = 'ãã£ã¨è¦ã'; 41 42 const arrowElement = document.createElement('div'); 43 arrowElement.textContent = "\u2228"; 44 arrowElement.classList.add('toc_button__arrow'); 45 46 buttonElement.appendChild(arrowElement); 47 this.rootElement.appendChild(buttonElement); 48 this.button = buttonElement; 49 } 50}
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.