PageSourceSearch

https://employeecivilrightsgroup.com/wp-content/themes/ecrg/js/main.js?ver=7.0.4

js employeecivilrightsgroup.com collected 2026-10-05 18:05:14 UTC 12,581 bytes, 369 lines download raw bytes

1jQuery('document').ready(function ($) {
2
3
4    /* Mobile Menu start ---- Full Menu Bar JS */
5    if ($('.menu-sidebar .menu-bar-wrapper li').hasClass('menu-item-has-children')) {
6        $(".menu-sidebar .menu-item-has-children > a").after("<span class='sidebar-menu-arrow'></span>");
7    }
8
9    var $toggleButton = $('.menu-button'),
10            $menuWrap = $('.menu-wrap'),
11            $sidebarArrow = $('.sidebar-menu-arrow');
12    // Hamburger Button
13    $toggleButton.on('click', function () {
14        $(this).toggleClass('button-open');
15        $menuWrap.toggleClass('menu-show');
16    });
17    $('.sidebar-menu-arrow').click(function () {
18        $(this).next('.sub-menu').slideUp(300);
19        if ($(this).next().is(':visible')) {
20            $(this).next().slideUp(300);
21        } else {
22            $(this).next().slideDown(300);
23        }
24
25        if ($(this).hasClass('responsive-up-arrow')) {
26            $(this).removeClass('responsive-up-arrow');
27        } else {
28            $(this).addClass('responsive-up-arrow');
29        }
30    });
31    $('.menu-button').on('click', function () {
32        $('body').addClass('nav-open-menu');
33    });
34    $('.menu-close-button').click(function () {
35        $('.menu-wrap').removeClass('menu-show');
36        $('.menu-button').removeClass('button-open');
37        $('body').removeClass('nav-open-menu');
38    });
39    /* Mobile Menu End */
40
41
42    /*====== Header Search Popup =======*/
43    $('.header #global-search').click(function () {
44        $('body').addClass('search-open');
45        $('.search-panel').css('transform', 'translateY(0)');
46        $("#searchform").find('input:text').val('');
47    });
48    $('.search-close').click(function () {
49        $('body').removeClass('search-open');
50    });
51    $('.search-close').click(function () {
52        $('.search-panel').css('transform', 'translateY(-100%)');
53        $("#searchform").find('input:text').val('');
54    });
55
56    /*====== Header Search =======*/
57    $('<span class="custom_form_msg d-none">Required</span>').insertAfter('#header-search .search-field');
58    $("#header-search .search-btn").click(function () {
59        var searchinput_val = $('#header-search .search-field').val();
60        if (searchinput_val === '') {
61            $("#header-search .custom_form_msg").removeClass('d-none');
62        } else {
63            $("#header-search .custom_form_msg").addClass('d-none');
64        }
65    });
66    $('#header-search .search-field').bind('invalid', function () {
67        return false;
68    });
69
70    /*====== Sidebar Search =======*/
71    $('<span class="custom_form_msg d-none">Required</span>').insertAfter('#sidebar-search .search-field');
72    $("#sidebar-search .search-btn").click(function () {
73        var searchinput_val = $('#sidebar-search .search-field').val();
74        if (searchinput_val === '') {
75            $("#sidebar-search .custom_form_msg").removeClass('d-none');
76        } else {
77            $("#sidebar-search .custom_form_msg").addClass('d-none');
78        }
79    });
80    $('#sidebar-search .search-field').bind('invalid', function () {
81        return false;
82    });
83
84
85    /*** Autocomplete OFF ***/
86    $('input').attr('autocomplete', 'off');
87
88    //***** IPad Menu Double Click ****//
89    if ($(window).width() >= 767) {
90        $(function () {
91            $('#menu-primary-menu li:has(ul)').doubleTapToGo();
92        });
93    }
94
95    /*** Fixed Header ***/
96
97    $(window).scroll(function () {
98        if ($(document).scrollTop() > 1) {
99            $('.header').addClass('shrink');
100            $('body').addClass('header-fixed');
101        } else {
102            $('.header').removeClass('shrink');
103            $('body').removeClass('header-fixed');
104        }
105    });
106
107    if ($(document).scrollTop() > 1) {
108        $('.header').addClass('shrink');
109        $('body').addClass('header-fixed');
110    } else {
111        $('.header').removeClass('shrink');
112        $('body').removeClass('header-fixed');
113    }
114
115    /*** Window Loaded  ***/
116    $(window).on("load", function () {
117        $("body").addClass("body-loaded");
118    });
119
120
121    var headerHeight = $('header').outerHeight();
122
123    $(".scroll").on('click', function (event) {
124        if (this.hash !== "") {
125            // Prevent default anchor click behavior
126            event.preventDefault();
127
128            // Store hash
129            var hash = this.hash;
130            $('html, body').animate({
131                scrollTop: $(hash).offset().top - headerHeight
132            }, 1500, function () {
133
134                // Add hash (#) to URL when done scrolling (default click behavior)
135                //window.location.hash = hash;
136            });
137        } // End if
138    });
139
140    /* Validation Events for changing response CSS classes */
141    document.addEventListener('wpcf7invalid', function (event) {
142        $('.wpcf7-response-output').addClass('alert alert-danger');
143    }, false);
144    document.addEventListener('wpcf7spam', function (event) {
145        $('.wpcf7-response-output').addClass('alert alert-warning');
146    }, false);
147    document.addEventListener('wpcf7mailfailed', function (event) {
148        $('.wpcf7-response-output').addClass('alert alert-danger');
149    }, false);
150    document.addEventListener('wpcf7mailsent', function (event) {
151        $('.wpcf7-response-output').removeClass('alert-danger');
152        $('.wpcf7-response-output').addClass('alert alert-success');
153    }, false);
154
155
156    function init() {
157        var imgDefer = document.getElementsByTagName('img');
158        for (var i = 0; i < imgDefer.length; i++) {
159            if (imgDefer[i].getAttribute('data-src')) {
160                imgDefer[i].setAttribute('src', imgDefer[i].getAttribute('data-src'));
161            }
162        }
163    }
164    window.onload = init;
165
166
167    /***********js for svg*************/
168    jQuery(function () {
169        activate('img[src*=".svg"]');
170
171        function activate(string) {
172            jQuery(string).each(function () {
173                var $img = jQuery(this);
174                var imgID = $img.attr('id');
175                var imgClass = $img.attr('class');
176                var imgURL = $img.attr('src');
177
178                jQuery.get(imgURL, function (data) {
179                    // Get the SVG tag, ignore the rest
180                    var $svg = jQuery(data).find('svg');
181
182                    // Add replaced image's ID to the new SVG
183                    if (typeof imgID !== 'undefined') {
184                        $svg = $svg.attr('id', imgID);
185                    }
186                    // Add replaced image's classes to the new SVG
187                    if (typeof imgClass !== 'undefined') {
188                        $svg = $svg.attr('class', imgClass + ' replaced-svg');
189                    }
190
191                    // Remove any invalid XML tags as per http://validator.w3.org
192                    $svg = $svg.removeAttr('xmlns:a');
193
194                    // Replace image with new SVG
195                    $img.replaceWith($svg);
196
197                }, 'xml');
198            });
199        }
200    });
201
202    jQuery.validator.addMethod("validate_email", function (value, element) {
203        if (/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(value)) {
204            return true;
205        } else {
206            return false;
207        }
208    }, "Enter Valid Email Address");
209
210
211
212
213    // Custom validator
214    jQuery.validator.addMethod('validPhone', function (value, element) {
215        // Remove all non-digit characters to count digits only
216        const digitsOnly = value.replace(/\D/g, '');
217        
218        // Check: at least 10 digits, at most 20
219        const digitCountValid = digitsOnly.length >= 10 && digitsOnly.length <= 20;
220
221        // Check: only allowed characters in total string
222        const validCharsPattern = /^[0-9+\-\(\)\s]+$/;
223
224        return this.optional(element) || (validCharsPattern.test(value) && digitCountValid);
225    }, 'Please enter a valid phone number (10–20 digits, may include +, -, spaces, or parentheses).');
226    
227
228
229
230    jQuery(".wpcf7-form").on("click", function (e) {
231        jQuery(this).validate({
232            rules: {
233                FullName: "required",
234                FirstName: "required",
235                LastName: "required",
236                ServiceNeeded: "required",
237                CompanyName: "required",
238                Message: "required",
239                ChooseService: "required",
240                ExpectedCollegiateGraduationDate: "required",
241                GPA: "required",
242                HometownCity: "required",
243                HometownState: "required",
244                // PhoneNumber: "required",
245                PhoneNumber: {
246                required: true,
247                validPhone: true
248            },
249                EmailAddress: {
250                    required: true,
251                    validate_email: true
252                }
253            },
254
255            messages: {
256                FullName: "Enter Full Name",
257                FirstName: "Enter First Name",
258                LastName: "Enter Last Name",
259                PhoneNumber: "Enter Phone Number",
260                EmailAddress: {
261                    required: "Enter Email Address",
262                    email: "Enter Valid Email Address"
263                },
264                ChooseService: "Select Service",
265                CompanyName: "Enter Company Name",
266                Message: "Enter Your Message",
267                ExpectedCollegiateGraduationDate:"Enter Graduation Date",
268                GPA:"Enter GPA",
269                HometownCity:"Enter Hometown City",
270                HometownState:"Enter Hometown State",
271            }
272        });
273    });
274
275});
276
277
278jQuery('.wpcf7 input[type="text"], .wpcf7 input[type="email"], .wpcf7 textarea').bind('paste', function (e) {
279    e.preventDefault();
280});
281
282
283jQuery('.wpcf7').find('select option:first').val("");
284
285jQuery(function () {
286    setTimeout(function () {
287        jQuery('.wpcf7').find('select').addClass('wpcf7-not-valid');
288    }, 1000);
289});
290
291/* Name validation */
292
293jQuery("input[name='FirstName'], input[name='LastName']").keypress(function (e) {
294    if (e.which === 32) {
295        return false;
296    }
297});
298
299/*===== Disable Space on First Name  =====*/
300jQuery("input[name='FullName']").keypress(function (input) {
301    if (/^\s/.test(input.value)) {
302        input.value = '';
303    }
304});
305
306jQuery('.wpcf7-form input, .wpcf7-form textarea').on('keydown', function (e) {
307    if (e.which === 32 && e.target.selectionStart === 0) {
308        return false;
309    }
310});
311
312function validateName(event) {
313    var value = String.fromCharCode(event.which);
314    var pattern = new RegExp(/[a-zåäö ]/i);
315    return pattern.test(value);
316}
317jQuery("input[name='FirstName']").bind('keypress', validateName);
318jQuery("input[name='LastName']").bind('keypress', validateName);
319jQuery("input[name='FullName']").bind('keypress', validateName);
320
321/* Used to format phone number */
322// jQuery(document).ready(function ($) {
323//     // Remove CF7-imposed limits
324//     $('input[type="tel"]').removeAttr('maxlength minlength pattern');
325
326//     // Only allow numbers
327//     $('input[type="tel"]').on('input', function () {
328//         let sanitizedValue = $(this).val().replace(/\D/g, ''); // keep only digits
329//         $(this).val(sanitizedValue);
330
331//         // Show/hide CF7 error + jQuery Validate error
332//         if (sanitizedValue.length > 0) {
333//             $(this).siblings('.wpcf7-not-valid-tip').hide();
334//             $(this).siblings('label.error').hide();
335//         } else {
336//             $(this).siblings('.wpcf7-not-valid-tip').show();
337//             $(this).siblings('label.error').show();
338//         }
339//     });
340
341//     // Ensure error shows on blur/focus if empty
342//     $('input[type="tel"]').on('blur focus', function () {
343//         if ($(this).val().length === 0) {
344//             $(this).siblings('.wpcf7-not-valid-tip').show();
345//             $(this).siblings('label.error').show();
346//         }
347//     });
348// });
349// 
350// 
351// 
352// 
353 jQuery(document).ready(function ($) {
354  $("input[name='s'], input[name='FullName'], input[name='EmailAddress']").on("input", function () {
355    var value = $(this).val();
356
357    // Remove leading spaces
358    value = value.replace(/^\s+/, "");
359
360    // Replace multiple consecutive spaces with a single space
361    value = value.replace(/\s{2,}/g, " ");
362
363    // Update the input field with the cleaned value
364    $(this).val(value);
365  });
366});
367
368
369

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.