PageSourceSearch

https://www.flooredllc.com/js/essentials.js?v=151

js flooredllc.com collected 2026-10-05 23:55:31 UTC 10,672 bytes, 366 lines download raw bytes

1/*********************************
2 * Custom Sticky Topbar
3 * Custom Cookie Functions
4 * Alert Bar (uses cookies)
5 * Silent Salesman (uses cookies)
6 * Popup Box (uses cookies)
7 * 
8 * ******************************/
9
10
11
12
13//////////////////////////////////
14// Custom Sticky Topbar
15// animate header slide down after scroll past
16//////////////////////////////////
17
18function stickyScroll () {
19    'use strict';
20    var c, currentScrollTop = 0, navbar = $('.sticky-header'), didScroll;
21    
22    navbar.addClass('sticky');
23    $('#pageHeader').css('padding-top', navbar.height());
24    
25    $(window).scroll(function (event) {
26        didScroll = true;
27    });
28                   
29    setInterval(function() {
30        if (didScroll) {
31            hasScrolled();
32            didScroll = false;
33        }
34    }, 150);
35
36    function hasScrolled() {
37          var a = $(window).scrollTop();
38          var b = navbar.height();
39         
40          currentScrollTop = a;
41         
42          if (c < currentScrollTop && a > b + b) {
43            navbar.addClass("sticky-hide").addClass("stuck");
44            $('#headerSearchDropdown').foundation('close')
45          } else if (c > currentScrollTop && !(a <= b)) {
46            navbar.removeClass("sticky-hide");
47          }
48          c = currentScrollTop;
49          
50          if (c == 0) {
51              navbar.removeClass("sticky-hide").removeClass("stuck");
52          }
53         
54    }
55}
56
57
58//////////////////////////////////
59// Custom Force Mobile Menu
60// hides the main menu and shows the hamburger menu if the main menu wraps to two lines before the mobile breakpoint
61//////////////////////////////////
62
63function checkMenuHeight() {
64    
65    var menuContainer = $('#mainNav ul'), menuItem = $('#mainNav ul > li');
66    if (menuContainer.height() > menuItem.height()){
67        console.log('true');
68        $('.show-for-mobile').addClass('viewport-adjust-show');
69        $('.hide-for-mobile').addClass('viewport-adjust-hide');
70    }
71}
72
73
74
75
76
77
78//////////////////////////////////
79// Custom Cookie Functions
80//////////////////////////////////
81function setCookie(name,value,days) {
82    var expires = "";
83    if (days) {
84        var date = new Date();
85        date.setTime(date.getTime() + (days*24*60*60*1000));
86        expires = "; expires=" + date.toUTCString();
87    }
88    document.cookie = name + "=" + (value || "")  + expires + "; path=/";
89}
90function getCookie(name) {
91    var nameEQ = name + "=";
92    var ca = document.cookie.split(';');
93    for(var i=0;i < ca.length;i++) {
94        var c = ca[i];
95        while (c.charAt(0)==' ') c = c.substring(1,c.length);
96        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
97    }
98    return null;
99}
100function eraseCookie(name) {   
101    document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
102}
103
104
105//////////////////////////////////
106// Alert Bar
107//////////////////////////////////
108function alertBar(command,element) { // Use an IIFE to encapsulate your code and avoid conflicts
109    
110    function loadAlerts() {
111        var alertSlider = document.getElementById('alertSlider');
112        var alerts = alertSlider.children;
113    
114        for (let i=0; i<alerts.length; i++) {
115            let currAlert = alerts[i];
116            let alertCookieName = currAlert.getAttribute('data-cookie-name');
117            let alertCookieVal = currAlert.getAttribute('data-cookie-value');
118            
119            if (getCookie(alertCookieName) == alertCookieVal) {
120                currAlert.classList.add('cookie-delete');
121            } else {
122                eraseCookie(alertCookieName);
123            }
124        }
125        
126        $('.cookie-delete').remove();
127        
128        alertSlider = document.getElementById('alertSlider');
129        if (alertSlider.children[0]) {
130           alertSlider.children[0].classList.remove('hide'); 
131        }
132    }
133    
134    
135    function closeAlert() {
136        console.log(element);
137        var cookieName = element.getAttribute('data-value');
138        var currAlertBar = document.getElementById(cookieName);
139        var cookieValue = currAlertBar.getAttribute('data-cookie-value');
140        var nextAlertBar = currAlertBar.nextElementSibling;
141        
142        currAlertBar.classList.add('hide');
143        if (nextAlertBar) {
144            nextAlertBar.classList.remove('hide');
145        } else {
146            let navbar = $('.sticky-header');
147            $('#pageHeader').css('padding-top', navbar.height());
148        }
149        
150        setCookie(cookieName,cookieValue,7);
151        
152    }
153
154    switch(command) {
155      case 'load':
156        loadAlerts();
157        break;
158      case 'close':
159        closeAlert();
160        break;
161      default:
162        // code block
163    } 
164    
165}
166
167
168//////////////////////////////////
169// Silent Salesman
170//////////////////////////////////
171function cornerBox(options) {
172    let defaults = {
173        state: 'open',
174        delay: 0
175    };
176    var settings = $.extend({},defaults,options || {});
177    var cookieValue = $('#cornerBox').data('cookie-value');
178    var viewportWidth = document.documentElement.clientWidth;
179
180    function loadBox() {
181        let delay = settings.delay * 1000;
182        setTimeout(function(){
183          $('#cornerBox').css('display','block');
184          $('#cornerBox').fadeTo( 800 , 1); // .fadeTo( speed, opacity )
185        }, delay);
186        
187        if ( (settings.state == 'open') && (getCookie('cornerBox') != cookieValue) && (viewportWidth > 767) ) {
188            delay = delay + 600;
189            setTimeout(function() { 
190                toggleBox();
191                setCookie('cornerBox',cookieValue,7);
192            }, delay);
193        }
194    }
195    
196    function toggleBox() {
197        $('#cornerBox').toggleClass('open');
198        $('.cornerBox--content').toggle(300);
199    }
200    
201    loadBox();
202    $('.cornerBox--header').click(toggleBox);
203    
204}
205
206
207
208//////////////////////////////////
209// Popup Box
210//////////////////////////////////
211function popupReveal(options) {
212    let defaults = {
213        type: 'load',
214        delay: 0,
215        views: 0,
216        start_date: null,
217        end_date: null,
218        last_modified: null,
219    };
220    
221    var settings = $.extend({}, defaults, options || {});
222    
223    console.log(settings);
224    
225    // Check that a popup is being called
226    if (!settings.id) {
227        return console.log('No Popup Selected');
228    }
229    
230    // Use last_modified_time in the cookie key to force popup on updates
231    var modalId = 'popup' + settings.id;
232    var modifiedKey = settings.last_modified ? modalId + '_modified_' + settings.last_modified : modalId;
233    var popupClosed = getCookie(modifiedKey);
234    let pageCount = getCookie(modifiedKey + 'PageCount');
235    
236    console.log('last-modified:' + modifiedKey);
237    console.log('popup-closed:' + popupClosed);
238    console.log('page-count:' + pageCount);
239    
240    // Check if the popup has been seen & erase unnecessary cookies
241    if (popupClosed) {
242        if (pageCount) {
243            eraseCookie(modifiedKey + 'PageCount', 0, 7);
244        }
245        return;
246    }
247    
248    // If no page count, set it to 0
249    if (!pageCount) {
250        pageCount = 0;
251    }
252    
253    var $modal = new Foundation.Reveal($('#' + modalId), { animationIn: 'fade-in' });
254    
255    let currentDate = new Date();
256    let startDate = settings.start_date ? new Date(settings.start_date) : null;
257    let endDate = settings.end_date ? new Date(settings.end_date) : null;
258
259    if (startDate && currentDate < startDate) {
260        return;
261    }
262
263    if (endDate && currentDate > endDate) {
264        return;
265    }
266
267    if (pageCount >= settings.views) {
268        switch (settings.type) {
269            case 'scroll':
270                let didScroll;
271                $(window).scroll(function (event) {
272                    didScroll = true;
273                });
274
275                setInterval(function () {
276                    if (didScroll) {
277                        pageScroll();
278                        didScroll = false;
279                    }
280                }, 150);
281                break;
282            case 'leave':
283                pageLeave();
284                break;
285            default:
286                pageLoad();
287                break;
288        }
289    } else {
290        // Count the page view and save to cookie
291        pageCount++;
292        setCookie(modifiedKey + 'PageCount', pageCount, 7);
293    }
294
295    function pageLoad() {
296        setTimeout(function () { $modal.open(); }, (settings.delay * 1000));
297        setCookie(modifiedKey, true, 7);
298    }
299
300    function pageLeave() {
301        $('body').mouseleave(function () {
302            if (!popupClosed) {
303                $modal.open();
304                setCookie(modifiedKey, true, 7);
305                popupClosed = true;
306            }
307        });
308    }
309
310    function pageScroll() {
311        if ($(window).scrollTop() > 250 && !popupClosed) {
312            $modal.open();
313            setCookie(modifiedKey, true, 7);
314            popupClosed = true;
315        }
316    }
317}
318
319function applyLazyLoadBelowFold() {
320    const images = document.querySelectorAll('.applied-settings img');
321
322    images.forEach(img => {
323        const rect = img.getBoundingClientRect();
324
325        // Check if the image is below the fold
326        if (rect.top > window.innerHeight) {
327            // Apply lazy loading only to images below the fold
328            if (!img.hasAttribute('loading')) {
329                img.setAttribute('loading', 'lazy');
330            }
331        }
332    });
333}
334
335function honeypotInitialization() {
336    var forms = document.querySelectorAll('form:not(#search_box_form)');
337    
338    forms.forEach(function(form) {
339        // Create honeypot label
340        var honeypotLabel = document.createElement('label');
341        honeypotLabel.htmlFor = 'email_confirm';
342        honeypotLabel.textContent = 'Confirm Email';
343        honeypotLabel.classList.add('confirm_email_field');
344        honeypotLabel.setAttribute('aria-hidden', 'true');
345        honeypotLabel.setAttribute('tabindex', '-1');
346        
347        // Create honeypot input
348        var honeypot = document.createElement('input');
349        honeypot.type = 'text';
350        honeypot.name = 'email_confirm_' + Math.random().toString(36).substring(7);
351        honeypot.id = 'email_confirm';
352        honeypot.classList.add('confirm_email_field');
353        honeypot.setAttribute('aria-hidden', 'true');
354        honeypot.setAttribute('tabindex', '-1');
355        
356        form.appendChild(honeypotLabel);
357        form.appendChild(honeypot);
358        
359        form.addEventListener('submit', function(event) {
360            if (honeypot.value !== '') {
361                event.preventDefault();
362                alert('Error: Please call us if the issue persists.');
363            }
364        });
365    });
366}

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.