PageSourceSearch

https://sanfordheisler.com/wp-content/themes/law-theme/js/scripts.js?ver=1.0.68

js sanfordheisler.com collected 2026-10-01 14:08:34 UTC 11,885 bytes, 410 lines download raw bytes

1var mouse_is_inside = false;
2
3jQuery(document).ready(function($) {
4   
5   console.log('HREF:', window.location.href);
6   console.log('SEARCH:', window.location.search);
7
8   const gclidStorageKey = 'firmPilotGclid';
9   const urlParams       = new URLSearchParams(window.location.search);
10
11   let gclid = urlParams.get('gclid');
12
13   console.log('GCLID URL:', gclid);
14   console.log('GCLID SESSION BEFORE:', sessionStorage.getItem(gclidStorageKey));
15
16   if (gclid) {
17      gclid = gclid.replace(/[^\w\-]/g, '').substring(0, 254);
18
19      if (gclid) {
20         sessionStorage.setItem(gclidStorageKey, gclid);
21      }
22   }
23
24   console.log('GCLID SESSION AFTER:', sessionStorage.getItem(gclidStorageKey));
25
26    // const stickyHeader = $('#sticky-header');
27    // $(window).scroll(function () {
28    //     if ($(this).scrollTop() > 200) {
29    //         stickyHeader.css('position', 'fixed');
30    //         stickyHeader.addClass('sticky');
31    //     } else {
32    //         stickyHeader.css('position', 'static');
33    //         stickyHeader.removeClass('sticky');
34    //     }
35    // });
36
37    //**
38    // load more videos 
39    //**
40    let page = 2;
41
42    $('#load-more-videos').on('click', function () {
43        let button = $(this);
44        button.prop('disabled', true).text('Loading...');
45
46        $.post(wpr_scripts.ajax_url, {
47            action: 'load_more_videos',
48            page: page
49        }, function (response) {
50            if ($.trim(response)) {
51                $('.videos-grid').append(response);
52                page++;
53                button.prop('disabled', false).text('Load More');
54            } else {
55                button.hide();
56            }
57        });
58    });
59
60    //**
61    // header search 
62    //**
63    $('#serch-icon').click(function(e){
64        $('.top-search-form').toggleClass('active');
65        $(this).hide();
66        // e.preventDefault();
67    });
68
69    $('.top-search-form').hover(function(){ 
70        mouse_is_inside=true; 
71    }, function(){ 
72        mouse_is_inside=false; 
73    });
74
75    $("body").mouseup(function(){ 
76       // if(! mouse_is_inside) $('.top-search-form').hide();
77        $('#serch-icon').show();
78        if(! mouse_is_inside) $('.top-search-form').removeClass('active');
79    });
80
81    //**
82    // sidebar menus
83    //**
84    $('.menu-who-we-are .elementor-nav-menu').removeClass('sm-vertical');
85    
86    $( '<a href="#" class="submenu-icons"></a>' ).insertAfter( '.menu-who-we-are .elementor-nav-menu li.menu-item-has-children>a' );
87    $( '<a href="#" class="submenu-icons"></a>' ).insertAfter( '.menu-who-we-are .menu li.menu-item-has-children>a' );
88
89    $(".menu-who-we-are .menu li.current-menu-item").each(function (index, value) { 
90        $(this).closest('.sub-menu').show();
91        $(this).closest('.submenu-icons').addClass('active');
92    })
93
94    $('.submenu-icons').on('click', function (e) {
95        e.preventDefault();
96        let submenu = $(this);
97        submenu.toggleClass('active');
98        let parent = submenu.closest('.menu-item-has-children')
99        parent.find('.sub-menu').toggle();
100    });
101
102    //**
103    // fit videos on pages content
104    //**
105    $(function () {
106      if ($.fn.fitVids) {
107        $('.elementor-widget-container, .elementor-widget-text-editor').fitVids({
108          customSelector: "iframe[src^='https://www.youtube-nocookie.com'], iframe[src^='https://www.youtube.com'], iframe[src^='https://www.dailymotion.com'], iframe[src^='https://www.funnyordie.com'], iframe[src^='https://embed-ssl.ted.com'], iframe[src^='https://embed.revision3.com'], iframe[src^='https://flickr.com'], iframe[src^='https://blip.tv'], iframe[src^='https://www.collegehumor.com']"
109        });
110      }
111    });
112
113    /**
114     * Dynamically sets a custom download filename for a template link in Gravity Forms
115     * The filename format is: [YYYY-MM-DD] Sanford Heisler Sharp McKnight's Template Bio.docx
116     */
117    let $link = $('#bioTemplateDownload');
118    if ($link.length) {
119        let today = new Date();
120        let yyyy = today.getFullYear();
121        let mm = String(today.getMonth() + 1).padStart(2, '0'); // Ay
122        let dd = String(today.getDate()).padStart(2, '0'); // Gün
123        let formattedDate = `${yyyy}-${mm}-${dd}`;
124
125        let newFileName = `${formattedDate}
125 Sanford Heisler Sharp McKnight's Template Bio.docx`;
126
127        $link.attr('download', newFileName);
128    }
129});
130
131// GravityForm ID3 START
132
133// Age function validation
134function validateAgeField() {
135    const ageInput = document.getElementById('input_3_11');
136    
137    if (!ageInput) return;
138    
139    ageInput.addEventListener('blur', function() {
140        const value = this.value.trim();
141
142        removeErrorMessage(this);
143        
144        // Check if field is empty
145        if (value === '') {
146            showError(this, 'Age is required.');
147            return;
148        }
149        
150        // Regex: only numbers (0-9)
151        const regex = /^[0-9]+$/;
152        if (!regex.test(value)) {
153            showError(this, 'Age must only contain numbers.');
154            return;
155        }
156
157        // Validate field
158        this.classList.remove('gfield_error');
159    });
160}
161
162// Pronoun function validation
163function validatePronounField() {
164    const pronounInput = document.getElementById('input_3_10');
165    
166    if (!pronounInput) return;
167    
168    // focus validation
169    pronounInput.addEventListener('blur', function() {
170        const value = this.value.trim();
171        
172        removeErrorMessage(this);
173        
174        // Check if field is empty
175        if (value === '') {
176            showError(this, 'Pronoun(s) is required.');
177            return;
178        }
179
180        // Validate field
181        this.classList.remove('gfield_error');
182    });
183}
184
185// Gender function validation
186function validateGenderField() {
187    const genderInput = document.getElementById('input_3_9');
188    if (!genderInput) return;
189
190    genderInput.addEventListener('blur', function() {
191        const value = this.value.trim();
192
193        removeErrorMessage(this);
194
195        // Check if field is empty
196        if (value === '') {
197            showError(this, 'Gender is required.');
198            return;
199        }
200
201        // Check if field has only letters
202        const regex = /^[A-Za-z]+$/;
203        if (!regex.test(value)) {
204            showError(this, 'Gender must only contain letters.');
205            return;
206        }
207
208        // Validate field
209        this.classList.remove('gfield_error');
210    });
211}
212
213
214// Race function validation
215function validateRaceField() {
216    const raceInput = document.getElementById('input_3_8');
217    if (!raceInput) return;
218
219    raceInput.addEventListener('blur', function() {
220        const value = this.value.trim();
221
222        removeErrorMessage(this);
223
224        // Check if field is empty
225        if (value === '') {
226            showError(this, 'Race is required.');
227            return;
228        }
229
230        // Validate field
231        this.classList.remove('gfield_error');
232    });
233}
234
235// Email function validation
236function validateEmailField() {
237    const emailInput = document.getElementById('input_3_5');
238    
239    if (!emailInput) return;
240    
241    emailInput.addEventListener('blur', function() {
242        const value = this.value.trim();
243
244        removeErrorMessage(this);
245
246        // Check if field is empty
247        if (value === '') {
248            showError(this, 'Email is required.');
249            return;
250        }
251
252        // Regex simplu pentru email: [email protected]
253        const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
254
255        if (!emailRegex.test(value)) {
256            showError(this, 'Email must be formatted as [email protected].');
257            return;
258        }
259
260        // Validate field
261        this.classList.remove('gfield_error');
262    });
263}
264
265// Phone function validation
266function validatePhoneField() {
267    const phoneInput = document.getElementById('input_3_6');
268    if (!phoneInput) return;
269
270    phoneInput.addEventListener('input', function () {
271        let value = this.value;
272
273        // removes letters
274        value = value.replace(/[A-Za-z]/g, '');
275
276        // removes unwanted caracters
277        value = value.replace(/[^\d()\- x]/g, '');
278
279        // deletes multiple spaces
280        value = value.replace(/\s+/g, ' ');
281
282        // extract only numbers
283        let digits = value.replace(/[^\d]/g, '');
284
285        let formatted = '';
286
287        // (###)
288        if (digits.length > 0) {
289            formatted = '(' + digits.substring(0, 3);
290        }
291        if (digits.length >= 3) {
292            formatted += ') ';
293        }
294
295        // (###) ###
296        if (digits.length >= 4) {
297            formatted += digits.substring(3, 6);
298        }
299
300        // (###) ###-####
301        if (digits.length >= 7) {
302            formatted += '-' + digits.substring(6, 10);
303        }
304
305        // extension x######## (max 8)
306        if (digits.length > 10) {
307            let ext = digits.substring(10, 18); // max 8
308            formatted += ' x' + ext;
309        }
310
311        this.value = formatted;
312    });
313
314    phoneInput.addEventListener('blur', function () {
315        const value = this.value.trim();
316
317        removeErrorMessage(this);
318
319        if (value === '') {
320            showError(this, 'Phone number is required.');
321            return;
322        }
323
324        // validare minimă și maximă
325        const phoneRegex = /^\(\d{3}\) \d{3}-\d{4}( x\d{1,8})?$/;
326
327        if (!phoneRegex.test(value)) {
328            showError(this, 'Phone must be formatted as ###-###-#### x####.');
329            return;
330        }
331
332        this.classList.remove('gfield_error');
333    });
334}
335
336// Function to display error
337function showError(element, message) {
338    element.classList.add('gfield_error');
339    element.setAttribute('aria-invalid', 'true');
340    
341    // Find field container
342    const fieldContainer = element.closest('.gfield');
343    if (fieldContainer) {
344        fieldContainer.classList.add('gfield_error');
345        
346        // Add error message
347        let errorDiv = fieldContainer.querySelector('.validation_message');
348        if (!errorDiv) {
349            errorDiv = document.createElement('div');
350            errorDiv.className = 'gfield_description validation_message';
351            errorDiv.style.color = '#ffffff';
352            errorDiv.style.backgroundColor = '#cc2a24';
353            errorDiv.style.padding = '6px 8px';
354            element.parentNode.appendChild(errorDiv);
355        }
356        errorDiv.textContent = message;
357    }
358}
359
360// Function to remove error message
361function removeErrorMessage(element) {
362    element.classList.remove('gfield_error');
363    element.setAttribute('aria-invalid', 'false');
364    
365    const fieldContainer = element.closest('.gfield');
366    if (fieldContainer) {
367        fieldContainer.classList.remove('gfield_error');
368        const errorDiv = fieldContainer.querySelector('.validation_message');
369        if (errorDiv) {
370            errorDiv.remove();
371        }
372    }
373}
374
375//**
376// Search Bar to FacetWP Redirection
377//**
378const searchForms = document.querySelectorAll(".e-search-form");
379
380if (searchForms.length) {
381    searchForms.forEach((form) => {
382        form.addEventListener("submit", (e) => {
383            e.preventDefault();
384
385            const searchInput = form.querySelector('input[name="s"]');
386            if (!searchInput || !searchInput.value.trim()) return;
387
388            const searchTerm = searchInput.value.trim();
389            const paramName = "fwp_search_tabs";
390
391            const currentUrl = new URL(window.location.origin + "/");
392            currentUrl.searchParams.set(paramName, searchTerm);
393            currentUrl.searchParams.set("s", searchTerm);
394
395            window.location.href = currentUrl.toString();
396        });
397    });
398}
399
400// Initialize on page load
401document.addEventListener('DOMContentLoaded', function() {
402    validateRaceField();
403    validateGenderField();
404    validatePronounField();
405    validateAgeField();
406    validateEmailField();
407    validatePhoneField();
408});
409
410// GravityForm ID3 END

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.