PageSourceSearch

https://www.townofatlanticbeachsc.com/runtime/scripts/custom.js

js townofatlanticbeachsc.com collected 2026-10-02 14:40:28 UTC 8,941 bytes, 278 lines download raw bytes

1var ezTaskJS;
2
3// ---------------------------
4// 🔥 EARLY FIX (FIRST-RUN aria-hidden issue)
5// ---------------------------
6(function () {
7    document.addEventListener("focusin", function () {
8        var active = document.activeElement;
9        if (!active) return;
10
11        var hiddenParent = active.closest('[aria-hidden="true"]');
12
13        if (hiddenParent) {
14            var fallback = document.querySelector("#headerwrapper a");
15
16            if (fallback) {
17                fallback.focus();
18            } else {
19                active.blur();
20            }
21        }
22    }, true);
23})();
24
25$(document).on("ready", function () {
26
27    ezTaskJS = (function (window, document, undefined) {
28
29        'use strict';
30
31        var settings = {
32            version: "1.0.4",
33            docHeight: function () {
34                var height = $(document).height();
35                var windowHeight = window.innerHeight;
36
37                if (height <= windowHeight) {
38                    setTimeout(function () {
39                        return $(document).height();
40                    }, 0);
41                } else {
42                    return height;
43                }
44            }
45        };
46
47        return {
48
49            throttle: function (func, limit) {
50                var wait = false;
51                limit = limit || 200;
52                return function () {
53                    if (!wait) {
54                        func.call();
55                        wait = true;
56                        setTimeout(function () {
57                            wait = false;
58                        }, limit);
59                    }
60                };
61            },
62
63            debounce: function (func, wait, immediate) {
64                var timeout;
65                return function () {
66                    var context = this,
67                        args = arguments;
68
69                    var later = function () {
70                        timeout = null;
71                        if (!immediate) func.apply(context, args);
72                    };
73
74                    var callNow = immediate && !timeout;
75
76                    clearTimeout(timeout);
77                    timeout = setTimeout(later, wait || 200);
78
79                    if (callNow) func.apply(context, args);
80                };
81            },
82
83            copyrightDate: function () {
84                var el = $("#ezcopyright");
85                if (!el.length) return;
86                el.html(new Date().getFullYear());
87            },
88
89            removeEmptyHeadings: function () {
90                if (window.location.pathname == "/design/Editor.aspx") return;
91
92                $("h1,h2,h3,h4,h5,h6").each(function () {
93                    var $this = $(this);
94                    if (!$this.text().trim() && !$this.find("img").length) {
95                        $this.remove();
96                    }
97                });
98            },
99
100            scrollToTop: function (element) {
101                var $el = $("#" + element);
102                if (!$el.length) return;
103
104                $(window).on("scroll", function () {
105                    $el.toggleClass("scroll-visible", window.scrollY > 0);
106                });
107
108                $el.on("click", function () {
109                    window.scrollTo({ top: 0, behavior: "smooth" });
110                });
111            },
112
113            headerEffect: function () {
114
115                if (window.location.pathname == "/design/Editor.aspx" ||
116                    (window.ezUtilities && ezUtilities.isMobile)) return;
117
118                var $header = $("#headerwrapper");
119                if (!$header.length) return;
120
121                if (window.innerWidth > 700) {
122
123                    var $body = $("body");
124                    var headerHeight = $header.outerHeight();
125                    var top = $header.offset().top;
126
127                    var raf = window.requestAnimationFrame || function (fn) { fn(); };
128
129                    $(window).on("scroll", function () {
130                        raf(function () {
131                            if ((window.scrollY || window.pageYOffset) > (top + headerHeight)) {
132                                $header.addClass("headerfixed");
133                                $body.css("padding-top", headerHeight + "px");
134                            } else {
135                                $header.removeClass("headerfixed");
136                                $body.css("padding-top", 0);
137                            }
138                        });
139                    });
140                }
141            },
142
143            searchEffect: function () {
144                var $searchIcon = $("#searchboxicon");
145                var $searchbox = $("#searchbox");
146                if (!$searchIcon.length || !$searchbox.length) return;
147            },
148
149            showCustomDrop: function () {
150
151                var $button = $("#customdrop");
152                var $drop = $(".custom-drop");
153                var $center = $drop.eq(0);
154
155                if (!$button.length || !$drop.length) return;
156
157                var isOpen = false;
158
159                $button.on("click", function (e) {
160                    e.preventDefault();
161
162                    if (!isOpen) {
163                        $drop.show();
164                        $center.attr({ 'tabindex': '-1', 'aria-expanded': 'true' });
165                        $button.attr('aria-expanded', 'true');
166
167                        setTimeout(function () {
168                            $center.focus();
169                        }, 0);
170
171                        isOpen = true;
172                    } else {
173                        $center.removeAttr('tabindex aria-expanded');
174                        $drop.hide();
175                        isOpen = false;
176                    }
177                });
178
179                $drop.add($button).on("keyup", function (e) {
180                    if (e.which == 27 && isOpen) {
181                        $center.removeAttr('tabindex aria-expanded');
182                        $button.attr('aria-expanded', 'false');
183                        $drop.hide();
184                        isOpen = false;
185                        $button.focus();
186                    }
187                });
188            },
189
190            setGoogleSearchPlaceholder: function () {
191
192                var observer = new MutationObserver(function () {
193
194                    var el = document.getElementById('gsc-i-id1');
195
196                    if (el) {
197                        el.placeholder = "Search the site and press Enter";
198                        observer.disconnect();
199                    }
200
201                });
202
203                observer.observe(document.body, {
204                    childList: true,
205                    subtree: true
206                });
207            }
208
209        };
210
211    }(window, document));
212
213    if (ezTaskJS) {
214        ezTaskJS.copyrightDate();
215        ezTaskJS.removeEmptyHeadings();
216        ezTaskJS.headerEffect();
217        ezTaskJS.searchEffect();
218        ezTaskJS.showCustomDrop();
219        ezTaskJS.scrollToTop("scrolltotop");
220        ezTaskJS.setGoogleSearchPlaceholder();
221    }
222
223    // ---------------------------
224    // 🔥 FINAL ADA FIX (REAL FIX)
225    // ---------------------------
226
227    (function () {
228
229        var observer = new MutationObserver(function (mutations) {
230
231            mutations.forEach(function (mutation) {
232
233                if (mutation.type === "attributes" && mutation.attributeName === "aria-hidden") {
234
235                    var el = mutation.target;
236
237                    if (el.getAttribute("aria-hidden") === "true") {
238
239                        // 🔥 REMOVE FOCUSABILITY
240                        var focusable = el.querySelectorAll("a, button, input, select, textarea, [tabindex]");
241
242                        focusable.forEach(function (node) {
243                            node.setAttribute("tabindex", "-1");
244                        });
245
246                        // 🔥 FIX CURRENT FOCUS
247                        var active = document.activeElement;
248
249                        if (active && el.contains(active)) {
250
251                            var fallback = document.querySelector("#headerwrapper a");
252
253                            if (fallback) {
254                                fallback.focus();
255                            } else {
256                                active.blur();
257                            }
258                        }
259                    }
260                }
261
262            });
263
264        });
265
266        observer.observe(document.body, {
267            attributes: true,
268            subtree: true,
269            attributeFilter: ["aria-hidden"]
270        });
271
272    })();
273
274    if (window.location.pathname == "/design/Editor.aspx") {
275        $("body").addClass("editor");
276    }
277
278});

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.