PageSourceSearch

https://www.gedersdorf.at/system/statV.1789655742/JavaScript/MenuAdapter.js

js gedersdorf.at collected 2026-10-02 20:06:06 UTC 9,265 bytes, 239 lines download raw bytes

1var hoverClass = "Menu-Hover";
2var topmostClass = "Menu";
3var topmostClass2 = "megamenu";
4var isTouch;
5var lastlink;
6function Hover__AspNetMenu(element)
7{
8////    AddClassUpward__CssFriendlyAdapters(element.firstChild /* gets the inner SPAN or A */, topmostClass, hoverClass);
9//    AddClass__CssFriendlyAdapters(element, hoverClass);
10
11    //    AddClassUpward__CssFriendlyAdapters(element.firstChild /* gets the inner SPAN or A */, topmostClass, hoverClass);
12    if (element.tagName == "A") {
13        element = element.parentNode;
14
15        var ul = element.parentNode; // ul
16        if (ul.tagName == 'UL') {
17            var toHide;
18            for (toHide = 0; toHide < ul.children.length; toHide++) {
19                //console.log(toHide + ': ' + ul.children[toHide].tagName);
20                if (ul.children[toHide] != element)
21                    Unhover__AspNetMenu(ul.children[toHide]);
22            }
23        }
24        clearTimeout(hidetimer);
25
26        //        var found = false;
27        //        var help;
28        //        var test = 20;
29        //        help = element;
30        //        while (help != undefined && help.tagName != 'DIV' && !found && test > 0) {
31        //            console.log(help.tagName);
32        //            if (elemtohide == help)
33        //                found = true;
34        //            help = help.parentNode;
35        //            test = test - 1;
36        //        }
37        //        if (test == 0) alert("net gut");
38        //        console.log("found: " + found);
39
40        //        if(found)
41        //            clearTimeout(hidetimer);
42    }
43    //AddClass__CssFriendlyAdapters(element, hoverClass);
44    element.classList.add(hoverClass);
45
46}
47
48var elemtohide;
49var hidetimer;
50function Unhover__AspNetMenu2() {
51    //RemoveClass__CssFriendlyAdapters(elemtohide, hoverClass);
52    elemtohide.classList.remove(hoverClass);
53    clearTimeout(hidetimer);
54
55}
56
57function Unhover__AspNetMenu(element)
58{
59////    RemoveClassUpward__CssFriendlyAdapters(element.firstChild /* gets the inner SPAN or A */, topmostClass, hoverClass);
60    //    RemoveClass__CssFriendlyAdapters(element, hoverClass);
61    
62    if (element.tagName == "A") {
63        elemtohide = element.parentNode;
64        hidetimer = setTimeout(Unhover__AspNetMenu2, 50);
65    }
66    else
67    { 
68        element.classList.remove(hoverClass);
69        //RemoveClass__CssFriendlyAdapters(element, hoverClass); 
70    }
71}
72
73function SetHover__AspNetMenu()
74{  
75    var menus = document.getElementsByTagName("ul");
76    for (var i = 0; i < menus.length; i++) {
77        if (menus[i].className == topmostClass || menus[i].parentElement.className == topmostClass2) {
78            var items = menus[i].getElementsByTagName("li");
79            for (var k = 0; k < items.length; k++) {
80                items[k].onmouseover = function () { Hover__AspNetMenu(this); }
81                items[k].onmouseout = function () { Unhover__AspNetMenu(this); }
82                //                items[k].onfocus = function () { Hover__AspNetMenu(this); }
83                //                items[k].onblur = function () { Unhover__AspNetMenu(this); }
84                //                items[k].onfocusin = function () { Hover__AspNetMenu(this); }
85                //                items[k].onfocusout = function () { Unhover__AspNetMenu(this); }
86            }
87        }
88    }
89
90    var links = document.getElementsByTagName("a");
91    for (var i = 0; i < links.length; i++) {
92        if (links[i].getAttribute("class") && links[i].getAttribute("class").indexOf("Menu-Link") >=0) {
93            links[i].onblur = function () {
94                Unhover__AspNetMenu(this);
95            }
96            links[i].onfocus = function () { Hover__AspNetMenu(this); }
97        }
98    }
99
100    // erster link des menüs, menü wird ausgeblendet nach blur rückwärts
101    document.querySelectorAll(".Menu").forEach(function (menu) {
102        var links = menu.querySelectorAll(".Menu-Link");
103        if (links.length > 0) {
104            links[links.length - 1].addEventListener('blur', function (event) {
105                if (event.relatedTarget != null) {
106                    if (!event.relatedTarget.classList.contains("Menu-Link")) {
107                        Unhover__AspNetMenu(menu.closest(".Menu-WithChildren"));
108                    }
109                }
110            });
111        }
112    });
113}
114
115//window.onload = SetHover__AspNetMenu;
116
117function pointerdownHandler (evt) {
118    if(evt.pointerType == "touch")
119        isTouch = true;
120    else
121        isTouch = false;
122}
123
124window.addEventListener('pointerdown', pointerdownHandler, false);
125
126window.onpageshow = function (event) {
127    if (event.persisted) {
128        document.querySelectorAll(".Menu ul").forEach(function (ul) {
129            ul.classList.remove("showhorizontalmenu");
130        });
131        document.querySelectorAll(".Menu li").forEach(function (li) {
132            li.classList.remove(hoverClass);
133        });
134    }
135};
136
137
138
139document.addEventListener('DOMContentLoaded', function() {
140    document.body.addEventListener('touchstart', function () {
141        isTouch = true;
142    });
143    
144    isTouch = false;
145    SetHover__AspNetMenu();
146    
147
148    document.querySelectorAll(".Menu-WithChildren > a").forEach(function (link) {
149        link.addEventListener('click', function (event) {
150            if (lastlink != this && isTouch == true) {
151                event.preventDefault();
152                // ul menu drunter aufklappen
153                var currentUl = this.nextElementSibling;
154                currentUl.classList.add("showhorizontalmenu");
155
156                // zuklapp logik
157                // alle .showmenu holen
158                document.querySelectorAll(".showhorizontalmenu").forEach(function (showmenuitem) {
159                    var childfound = false;
160
161                    if (showmenuitem.contains(currentUl) || showmenuitem === currentUl)
162                        childfound = true;
163
164                    if (!childfound)
165                        showmenuitem.classList.remove("showhorizontalmenu");
166                });
167            }
168            lastlink = this;
169        });
170    });
171
172    document.querySelectorAll(".mm-menuitem > a").forEach(function (link) {
173        link.addEventListener('click', function (event) {
174            if (lastlink != this && isTouch == true) {
175                event.preventDefault();
176                // ul menu drunter aufklappen
177                var currentUl = this.nextElementSibling;
178                currentUl.classList.add("showhorizontalmenu");
179
180                // zuklapp logik
181                // alle .showmenu holen
182                document.querySelectorAll(".showhorizontalmenu").forEach(function (showmenuitem) {
183                    var childfound = false;
184
185                    if (showmenuitem.contains(currentUl) || showmenuitem === currentUl)
186                        childfound = true;
187
188                    if (!childfound)
189                        showmenuitem.classList.remove("showhorizontalmenu");
190                });
191            }
192            lastlink = this;
193        });
194    });
195	
196
197    if (!isTouch) {
198        document.querySelectorAll(".mm-menuitem").forEach(function (menuItem) {
199            menuItem.addEventListener("mouseenter", function () {
200                if (menuItem.querySelector(".mm-block"))
201                    menuItem.querySelector(".mm-block").classList.add("showhorizontalmenu");
202            });
203            menuItem.addEventListener("mouseleave", function () {
204                if (menuItem.querySelector(".mm-block"))
205                    menuItem.querySelector(".mm-block").classList.remove("showhorizontalmenu");
206            });
207        });
208
209        document.querySelectorAll(".mm-menuitem > a").forEach(function (link) {
210            link.addEventListener("focusin", function () {
211                document.querySelectorAll(".mm-block").forEach(function (block) {
212                    block.classList.remove("showhorizontalmenu");
213                });
214                link.nextElementSibling.classList.add("showhorizontalmenu");
215            });
216        });
217
218        document.querySelectorAll(".megamenu").forEach(function (megamenu) {
219            var lastLink = megamenu.querySelector(".mm-block a:last-child");
220            if (lastLink) {
221                lastLink.addEventListener("focusout", function (event) {
222                    if (!event.relatedTarget || !event.relatedTarget.parentElement.classList.contains("MegaMenu-Leaf")) {
223                        lastLink.closest(".mm-block").classList.remove("showhorizontalmenu");
224                    }
225                });
226            }
227
228            var firstLink = megamenu.querySelector(".MegaMenu-WithChildren > a:first-child");
229            if (firstLink) {
230                firstLink.addEventListener("focusout", function (event) {
231                    if (!firstLink.parentElement.contains(event.relatedTarget)) {
232                        firstLink.parentElement.querySelector(".mm-block").classList.remove("showhorizontalmenu");
233                    }
234                });
235            }
236        });
237    }
238});
239

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.