PageSourceSearch

https://monroecountypa.gov/Content/Assets/scripts/main.js

js monroecountypa.gov collected 2026-10-02 07:15:50 UTC 8,983 bytes, 282 lines download raw bytes

1//////Makes top nav links to be clickable
2//$(document).ready(function () {
3//    if ($(window).width() > 1199) {
4//        $('a.nav-link.dropdown-toggle').click(function () {
5//            location.href = this.href;
6//        });
7//    }
8//});
9
10// Sticky navbar
11// =========================
12$(document).ready(function () {
13    if ($(window).width() > 980) {
14
15        // Custom function which toggles between sticky class (is-sticky)
16        var stickyToggle = function (sticky, stickyWrapper, scrollElement) {
17            var stickyHeight = sticky.outerHeight();
18            var stickyTop = stickyWrapper.offset().top;
19            if (scrollElement.scrollTop() >= stickyTop) {
20                stickyWrapper.height(stickyHeight);
21                sticky.addClass("is-sticky");
22            }
23            else {
24                sticky.removeClass("is-sticky");
25                stickyWrapper.height('auto');
26            }
27        };
28
29        // Find all data-toggle="sticky-onscroll" elements
30        $('[data-toggle="sticky-onscroll"]').each(function () {
31            var sticky = $(this);
32            var stickyWrapper = $('<div>').addClass('sticky-wrapper'); // insert hidden element to maintain actual top offset on page
33            sticky.before(stickyWrapper);
34            sticky.addClass('sticky');
35
36            // Scroll & resize events
37            $(window).on('scroll.sticky-onscroll resize.sticky-onscroll', function () {
38                stickyToggle(sticky, stickyWrapper, $(this));
39            });
40
41            // On page load
42            stickyToggle(sticky, stickyWrapper, $(window));
43        });
44    } else {
45        return false;
46    }
47});
48
49//// Sticky header
50//// =========================
51
52//$(document).ready(function () {
53//    if ($(window).width() > 980) {
54
55//        $(window).scroll(function () {
56//            if ($(window).scrollTop() >= 300) {
57//                $('header').addClass('fixed-header');
58//            }
59//            else {
60//                $('nav').removeClass('fixed-header');
61//            }
62//        });
63//    } else {
64//        return false;
65//    }
66//});
67
68function main() {
69    window.addEventListener('load', () => {
70        getFormOnSubmitFunction();
71        removeFormOnSubmitFunction();
72    });
73
74    document.addEventListener('submit', onClick);
75}
76
77/* END Google Recaptcha V3 Scripts */
78
79// Get all elements with the class 'container-fluid'
80let rows = document.getElementsByClassName('container-fluid');
81
82// Convert HTMLCollection to an array and iterate through each row
83Array.from(rows).forEach(row => {
84    // Check if the row has any visible child elements
85    const hasVisibleContent = Array.from(row.children).some(child =>
86        child.offsetHeight > 0 || child.offsetWidth > 0 || child.textContent.trim() !== ''
87    );
88
89    if (!hasVisibleContent) {
90        row.style.display = 'none';
91    }
92});
93
94///ENSURES INLINE STYLES TAKE PRECEDENCE
95//PRIMARY
96document.querySelectorAll('.bgPrimary *').forEach(el => {
97    if (!el.style.color) {
98        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
99    }
100});
101//SECONDARY
102document.querySelectorAll('.bgSecondary *').forEach(el => {
103    if (!el.style.color) {
104        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
105    }
106});
107
108
109///INFO
110document.querySelectorAll('.bgInfo *').forEach(el => {
111    if (!el.style.color) {
112        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
113    }
114});
115
116
117///SUCCESS
118document.querySelectorAll('.bgSuccess *').forEach(el => {
119    if (!el.style.color) {
120        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
121    }
122});
123
124
125//WARNING
126document.querySelectorAll('.bgWarning *').forEach(el => {
127    if (!el.style.color) {
128        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
129    }
130});
131
132
133///ALERTS
134document.querySelectorAll('.bgAlerts *').forEach(el => {
135    if (!el.style.color) {
136        el.style.color = '$white'; // or 'black', or a CSS variable like var(--text-dark)
137    }
138});
139
140
141///GRAY
142document.querySelectorAll('.bgGray *').forEach(el => {
143    if (!el.style.color) {
144        el.style.color = '$dark'; // or 'black', or a CSS variable like var(--text-dark)
145    }
146});
147
148
149
150///WHITE
151document.querySelectorAll('.bgWhite *').forEach(el => {
152    if (!el.style.color) {
153        el.style.color = '$dark'; // or 'black', or a CSS variable like var(--text-dark)
154    }
155});
156
157//added support for _blank fixes targeted for rich text
158document.addEventListener("DOMContentLoaded", function () {
159
160    document.querySelectorAll('a[target="_blank"]').forEach(function (link) {
161        // Add rel="noopener" if not present
162        if (!link.hasAttribute("rel")) {
163            link.setAttribute("rel", "noopener");
164        }
165
166        // Add aria-label warning if not already present
167        const linkText = link.textContent.trim();
168        const ariaLabel = link.getAttribute("aria-label");
169        if (!ariaLabel || !ariaLabel.toLowerCase().includes("opens in a new window")) {
170            link.setAttribute("aria-label", `${linkText} (opens in a new window)`);
171        }
172
173        // Add screen-reader text if not already inside
174        const hasSrOnly = Array.from(link.querySelectorAll(".sr-only"))
175            .some(el => el.textContent.includes("opens in a new window"));
176
177        if (!hasSrOnly) {
178
179            const srSpan = document.createElement("span");
180            srSpan.className = "sr-only";
181            srSpan.textContent = " (opens in a new window)";
182
183            link.appendChild(srSpan);
184        }
185    });
186});
187
188//REMOVES isPasted 
189document.addEventListener("DOMContentLoaded", function () {
190
191    // Find the element with id="isPasted"
192    var isPastedInput = document.getElementById("isPasted");
193    if (isPastedInput) {
194        // Remove only the id attribute — not the whole element
195        isPastedInput.removeAttribute("id");
196    }
197
198    // Prevent Kentico from re-adding it on paste events
199    document.addEventListener("paste", function (e) {
200        e.stopPropagation();
201        e.stopImmediatePropagation();
202    }, true); // capture
203
204});
205// Kentico-safe removal of isPasted ID
206(function () {
207
208    function stripIsPasted() {
209        document.querySelectorAll('[id="isPasted"]').forEach(function (el) {
210            el.removeAttribute('id');
211        });
212    }
213
214    // Run immediately
215    stripIsPasted();
216
217    // Run repeatedly because Kentico re-injects late
218    setInterval(stripIsPasted, 300);
219
220})();
221//fix Google Translate
222document.addEventListener("DOMContentLoaded", function () {
223
224    function fixGoogleTranslateAccessibility() {
225        const select = document.querySelector(".goog-te-combo");
226
227        if (select && !select.getAttribute("aria-label")) {
228            select.setAttribute("aria-label", "Translate this page");
229        }
230    }
231
232    // Run repeatedly because Google injects late
233    setInterval(fixGoogleTranslateAccessibility, 500);
234
235});
236////hide home page links when on home page
237//document.addEventListener("DOMContentLoaded", function () {
238//    // Only run on the home page
239//    var path = window.location.pathname.toLowerCase();
240
241//    if (path === "/") {
242//        // Select all links in main nav and utility nav pointing to Home
243//        var homeLinks = document.querySelectorAll(
244//            '#navbarSupportedContent a[href="/"], #navbarSupportedContent a[href="~/"], ' +
245//            '#navbarNavDropdown a[href="/"], #navbarNavDropdown a[href="~/"]'
246//        );
247
248//        homeLinks.forEach(function (link) {
249//            // Hide the entire <li> containing the link, or the link itself
250//            var li = link.closest('li');
251//            if (li) {
252//                li.style.display = 'none';
253//            } else {
254//                link.style.display = 'none';
255//            }
256//        });
257//    }
258//});
259//ADD ARIA LABEL FOR THEIR MENU 
260document.addEventListener('DOMContentLoaded', function () {
261    var elem = document.querySelector('.custom-w-lsidenav-withPageTitle');
262    if (elem) {
263        // Add ARIA label
264        elem.setAttribute('aria-label', 'Menu');
265
266        // Add hidden span for screen readers (scanner-friendly)
267        var srSpan = document.createElement('span');
268        srSpan.textContent = 'Menu';
269        srSpan.style.position = 'absolute';
270        srSpan.style.width = '1px';
271        srSpan.style.height = '1px';
272        srSpan.style.padding = '0';
273        srSpan.style.margin = '-1px';
274        srSpan.style.overflow = 'hidden';
275        srSpan.style.clip = 'rect(0 0 0 0)';
276        srSpan.style.whiteSpace = 'nowrap';
277        srSpan.style.border = '0';
278
279        // Insert as the first child
280        elem.prepend(srSpan);
281    }
282});

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.