PageSourceSearch

https://ttnworldwide.com/assets/js/accordion-menu.js

js ttnworldwide.com collected 2026-10-02 07:24:13 UTC 2,042 bytes, 53 lines download raw bytes

1let AccordionMenu = function(selector) {
2    this.colMenu = document.querySelectorAll(`${selector} li`);
3    let This = this;
4    this.colMenu.forEach(function(items) {
5        if (items.querySelector('ul')) {
6            items.firstElementChild.insertAdjacentHTML('beforeend', '<svg version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 451.847 451.847" xml:space="preserve"> <g> <path d="M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751 c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0 c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"/> </g> </svg>');
7
8            items.firstElementChild.onclick = function(e) {
9                e.preventDefault();
10                
11                let isTrue = this.parentElement.classList.toggle('open');
12
13                if (isTrue) {
14                    This.show(this.nextElementSibling);
15                } else {
16                    This.hide(this.nextElementSibling);
17                }
18            }
19        } 
20    })
21}
22
23// Show an element
24AccordionMenu.prototype.show = function(elem) {
25    // Get the natural height of the element
26    var getHeight = function() {
27        elem.style.display = 'block'; // Make it visible
28        var height = elem.scrollHeight + 'px'; // Get it's height
29        return height;
30    };
31
32    var height = getHeight(); // Get the natural height
33    elem.style.height = height; // Update the height
34    
35    setTimeout(function() {
36        elem.style.height = 'auto';
37    }, 350);
38};
39
40// Hide an element
41AccordionMenu.prototype.hide = function(elem) {
42    // Give the element a height to change from
43    elem.style.height = elem.scrollHeight + 'px';
44
45    // Set the height back to 0
46    setTimeout(function() {
47        elem.style.height = '0';
48    }, 110);
49
50    setTimeout(function() {
51        elem.style.display = '';
52    }, 700);
53};

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.