PageSourceSearch

https://www.colourfence.co.uk/wp-content/themes/salient-child/assets/js/custom-2.js

js colourfence.co.uk collected 2026-10-08 05:48:15 UTC 18,786 bytes, 412 lines download raw bytes

1formErrorMessageScrollPosition();
2gravityFormButtonAnimation();
3DKLazyLoad();
4
5function toggleLocalPages() {
6    setTimeout( function() {
7        let target_element = document.getElementById("local-page__row");
8        target_element.classList.toggle("local-page__row--show");
9    }, 0);
10}
11
12function formErrorMessageScrollPosition() {
13    let gformWrapperEl = document.querySelector('form .gform_wrapper');
14    if ( typeof gformWrapperEl !== 'undefined' && gformWrapperEl != null ) {
15        let submitButton = document.querySelectorAll(".gform_wrapper button[type=submit],.gform_wrapper input[type=submit]");
16        if(typeof submitButton !== 'undefined' &&
17            submitButton != null ) {
18            submitButton[0].addEventListener("click", function() {
19                setTimeout(function () {
20                    let gFormWrapper = document.querySelector('.gform_wrapper');
21                    if (gFormWrapper.classList.contains("gform_validation_error")) {
22                        let currentScrollPosition = window.scrollY || window.scrollTop || document.getElementsByTagName("html")[0].scrollTop;
23                        jQuery('html, body').animate({
24                            scrollTop: currentScrollPosition - 60
25                        }, 500);
26                    }
27                }, 550);
28            });
29        }
30    }
31}
32
33function gravityFormButtonAnimation() {
34    let gFormSubmitButton = Array.prototype.slice.call(document.querySelectorAll(".gform_body button[type=submit],.gform_body button[type=button]"), 0);
35    if( typeof gFormSubmitButton !== 'undefined' &&
36        gFormSubmitButton != null &&
37        gFormSubmitButton.length > 0
38    ) {
39        gFormSubmitButton.forEach(function(item) {
40            item.addEventListener("click", function(e) {
41                updateRequestFormatDropdown(e);
42                item.closest("form").submit();
43                let internalHtml = item.innerHTML;
44                item.disabled = true;
45                item.innerHTML = '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>';
46                setTimeout(function() {
47                    gravityFormButtonAnimation();
48                }, 1500);
49                setTimeout(function() {
50                    item.innerHTML = internalHtml;
51                    item.disabled = false;
52                }, 10000, internalHtml);
53            });
54        });
55    }
56}
57
58/* SEARCH FIELDS */
59if( typeof document.querySelector('.global-nav__upper li.search') !== 'undefined' &&
60    document.querySelector('.global-nav__upper li.search') !== null ) {
61    document.querySelector('.global-nav__upper li.search').addEventListener("click", function() {
62        document.querySelector('.global-header__searchcontainer').classList.add('active');
63        var searchFieldGlobal = document.getElementsByClassName('search-field--global');
64        if(typeof searchFieldGlobal !== 'undefined') {
65            [].forEach.call(searchFieldGlobal, function(searchField) {
66                searchField.focus({ focusVisible: true });
67                searchField.select();
68            });
69        }
70    });
71    document.querySelector('.global-header__searchclose').addEventListener("click", function() {
72        document.querySelector('.global-header__searchcontainer').classList.remove('active');
73    });
74}
75
76
77
78/*LAZY LOADING GALLERY IMAGES*/
79
80/* document.addEventListener("DOMContentLoaded", function() { */
81    /* setTimeout( function() { */
82
83        function DKLazyLoad() {
84            let lazyLoadAnchors = Array.prototype.slice.call(document.querySelectorAll(".dk-lazy--anchor"), 0);
85            let lazyLoadList = Array.prototype.slice.call(document.querySelectorAll(".dk-lazy--list"), 0);
86            let lazyLoadDiv = Array.prototype.slice.call(document.querySelectorAll(".dk-lazy--listdiv"), 0);
87            let lazyLoadThrottleTimeout;
88
89            if (lazyLoadThrottleTimeout) {
90                clearTimeout(lazyLoadThrottleTimeout);
91            }
92
93            lazyLoadThrottleTimeout = setTimeout(function () {
94                let scrollTop = window.pageYOffset;
95                if (lazyLoadAnchors.length > 0) {
96                    lazyLoadAnchors.forEach(function (a) {
97                        if( typeof a.dataset.imageSrc !== 'undefined' ) {
98                            a.style.backgroundImage = "url(" + a.dataset.thumbSrc + ")";
99                            a.classList.remove('dk-lazy--anchor');
100                        }
101                    });
102                }
103                if (lazyLoadList.length > 0) {
104                    lazyLoadList.forEach(function (li) {
105                        let anchorElement = li.children[0];
106                        if( typeof anchorElement.dataset.imageSrc !== 'anchorElement.dataset.imageSrc' ) {
107                            li.children[0].style.backgroundImage = "url(" + anchorElement.dataset.thumbSrc + ")";
108                            li.classList.remove('dk-lazy--list');
109                        }
110                    });
111                }
112                if (lazyLoadDiv.length > 0) {
113                    lazyLoadDiv.forEach(function (li) {
114                        if (typeof li.children[0] !== 'undefined') {
115                            if (typeof li.children[0].children[0] !== 'undefined') {
116                                let listDiv = li.children[0].children[0];
117                                if( typeof listDiv.dataset.imageSrc !== 'undefined' ) {
118                                    listDiv.style.backgroundImage = "url(" + listDiv.dataset.imageSrc + ")";
119                                    li.classList.remove('dk-lazy--listdiv');
120                                }
121                            }
122                        }
123                    });
124                }
125                if (lazyLoadAnchors.length == 0) {
126                    document.removeEventListener("scroll", DKLazyLoad);
127                    window.removeEventListener("resize", DKLazyLoad);
128                    window.removeEventListener("orientationChange", DKLazyLoad);
129                    let GalleryCategoryTab = Array.prototype.slice.call(document.querySelectorAll('.gallery-category__tab'), 0);
130                    if( typeof GalleryCategoryTab !== 'undefined' &&
131                        GalleryCategoryTab != null &&
132                        GalleryCategoryTab.length > 0 ) {
133                        GalleryCategoryTab.forEach(function (item) {
134                            item.removeEventListener('click', function (event) {
135                                DKLazyLoad();
136                            });
137                        });
138                    }
139                    let FlexSlider = Array.prototype.slice.call(document.querySelectorAll('.flexslider'), 0);
140                    if( typeof FlexSlider !== 'undefined' &&
141                        FlexSlider != null &&
142                        FlexSlider.length > 0 ) {
143                        FlexSlider.forEach(function (item) {
144                            item.removeEventListener('click', function (event) {
145                                DKLazyLoad();
146                            });
147                        });
148                    }
149                }
150            }, 1000);
151        }
152
153        document.addEventListener("scroll", DKLazyLoad);
154        window.addEventListener("resize", DKLazyLoad);
155        window.addEventListener("orientationChange", DKLazyLoad);
156        let GalleryCategoryTab = Array.prototype.slice.call(document.querySelectorAll('.gallery-category__tab'), 0);
157        if( typeof GalleryCategoryTab !== 'undefined' &&
158            GalleryCategoryTab != null &&
159            GalleryCategoryTab.length > 0 ) {
160            GalleryCategoryTab.forEach(function (item) {
161                item.addEventListener('click', function (event) {
162                    DKLazyLoad();
163                });
164            });
165        }
166        let FlexSlider = Array.prototype.slice.call(document.querySelectorAll('.flexslider'), 0);
167        if( typeof FlexSlider !== 'undefined' &&
168            FlexSlider != null &&
169            FlexSlider.length > 0 ) {
170            FlexSlider.forEach(function (item) {
171                item.addEventListener('click', function (event) {
172                    DKLazyLoad();
173                });
174            });
175        }
176    /* }, 500); */
177
178    if( typeof document.querySelector(".ginput_container_date .screen-reader-text") !== 'undefined' &&
179        document.querySelector(".ginput_container_date .screen-reader-text") != null ) {
180        let dateParent = Array.prototype.slice.call(document.querySelector(".ginput_container_date .screen-reader-text"), 0);
181        if( typeof dateParent !== 'undefined' &&
182            dateParent != null &&
183            dateParent.length > 0 )
184        {
185            dateParent.innerHTML= "Date Format: DD/MM/YYYY";
186        }
187    }
188
189
190    /*PRODUCTS SUB NAV SCROLL CONTROL*/
191
192    let subNavContent = Array.prototype.slice.call(document.querySelectorAll(".product-sub__nav-content"), 0);
193    function showHideTabsOnScroll() {
194        if( typeof subNavContent !== 'undefined' ) {
195            let headerExtraSpace = 36;
196            let headerOffsetHeight = document.getElementById("header-outer").offsetHeight - headerExtraSpace;
197            [].forEach.call(subNavContent, function (subNavContent) {
198                let targetEl = document.getElementById(subNavContent.id);
199                if( window.getComputedStyle(targetEl).display !== "none" ) {
200                    let bounding = targetEl.getBoundingClientRect();
201                    let tabsEl = Array.prototype.slice.call(document.querySelector("#"+subNavContent.id + " ul.
201wpb_tabs_nav.ui-tabs-nav"), 0);
202                    if( typeof tabsEl !== 'undefined' &&
203                        tabsEl !== null
204                    ) {
205                        if( bounding.bottom > (bounding.height/2) &&
206                            bounding.top < (headerOffsetHeight-headerExtraSpace)
207                        ) {
208                            tabsEl.classList.add("tabs-onscroll--show");
209                            tabsEl.style.position = 'fixed';
210                            tabsEl.style.top = headerOffsetHeight+'px';
211                            tabsEl.style.width = bounding.width+'px';
212                            tabsEl.style.paddingTop = headerExtraSpace+'px'
213                        } else {
214                            tabsEl.classList.remove("tabs-onscroll--show");
215                            tabsEl.style.removeProperty('position');
216                            tabsEl.style.removeProperty('top');
217                            tabsEl.style.removeProperty('width');
218                            tabsEl.style.removeProperty('padding-top');
219                        }
220                    }
221                }
222            });
223        }
224        if(subNavContent.length == 0) {
225            document.removeEventListener("scroll", showHideTabsOnScroll);
226            let WpbTabsNavUiTabsNavLiA = Array.prototype.slice.call(document.querySelectorAll('.wpb_tabs_nav.ui-tabs-nav li a'), 0);
227            if( typeof WpbTabsNavUiTabsNavLiA !== 'undefined' &&
228                WpbTabsNavUiTabsNavLiA != null &&
229                WpbTabsNavUiTabsNavLiA.length > 0 )
230            {
231                WpbTabsNavUiTabsNavLiA.forEach(function(item) {
232                    item.removeEventListener('click', function(event) {
233                        showHideTabsOnScroll();
234                    });
235                });
236            }
237        }
238    }
239    document.addEventListener("scroll", showHideTabsOnScroll);
240    let wpbTabsNavUiTabsNavLiA = Array.prototype.slice.call(document.querySelectorAll('.wpb_tabs_nav.ui-tabs-nav li a'), 0);
241    if( typeof wpbTabsNavUiTabsNavLiA !== 'undefined' &&
242        wpbTabsNavUiTabsNavLiA != null &&
243        wpbTabsNavUiTabsNavLiA.length > 0 ) {
244        wpbTabsNavUiTabsNavLiA.forEach(function (item) {
245            item.addEventListener('click', function (event) {
246                showHideTabsOnScroll();
247            });
248        });
249    }
250
251    /*PRODUCTS SUB NAV SCROLL CONTROL*/
252
253
254    /*ADDING CLASS TO PRE-BUILT MODULES PARENTS*/
255    let pbModules = jQuery(".pb-module");
256    pbModules.each( function() {
257        let $thisEl = jQuery(this);
258        let $rowEl = $thisEl.closest('.wpb_row.standard_section');
259        if( typeof $rowEl !== 'undefined' &&
260            $rowEl != null )
261        {
262            if( $rowEl.hasClass('row') ) {
263                $rowEl = checkParentElementClass($rowEl);
264            }
265            $rowEl.addClass('pb-module__parent');
266        }
267    });
268
269    function checkParentElementClass( customElement ) {
270        let returnVar = [];
271        let newParentElement = customElement.parentNode;
272        if( typeof newParentElement !== 'undefined' &&
273            newParentElement !== null) {
274            if( newParentElement.className == 'row') {
275                return customElement;
276            } else {
277                returnVar = checkParentElementClass(newParentElement);
278            }
279        }
280        return returnVar;
281    }
282    /*ADDING CLASS TO PRE-BUILT MODULES PARENTS*/
283
284    /*ADDING MASONRY GRID INITIALISATION ON SALIENT TABS*/
285    let WpbTabsNavUiTabsNavLiA = Array.prototype.slice.call(document.querySelectorAll('.wpb_tabs_nav.ui-tabs-nav li a'), 0);
286    if( typeof WpbTabsNavUiTabsNavLiA !== 'undefined' &&
287        WpbTabsNavUiTabsNavLiA != null &&
288        WpbTabsNavUiTabsNavLiA.length > 0 )
289    {
290        WpbTabsNavUiTabsNavLiA.forEach(function(item) {
291            item.addEventListener('click', function(event) {
292                masonaryJSGrid(300);
293            });
294        });
295    }
296    /*ADDING MASONRY GRID INITIALISATION ON SALIENT TABS*/
297
298    /*MAKING FOOTER NAVIGATION MENU WIDGETS TO ACCORDIONS ON MOBILE*/
299    let screen_width = screen.width;
300    if( screen_width < 673 ) {
301        footerNavMobileAccordionFn();
302    }
303    window.addEventListener("orientationChange", footerNavMobileAccordionFn);
304
305    function footerNavMobileAccordionFn() {
306        closeAllFooterWidgets();
307        footerNavMobileAccordion();
308    }
309
310    function footerNavMobileAccordion() {
311        document.querySelectorAll("#footer-outer .container .row .col").forEach(function(item) {
312            let accordionHeading = item.querySelector(".widget h4");
313            if( typeof accordionHeading !== 'undefined' && accordionHeading != null) {
314                accordionHeading.addEventListener("click", function(event) {
315                    event.preventDefault();
316                    let targetEl = event.target;
317                    if( typeof targetEl !== 'undefined' &&
318                        targetEl !== null) {
319                        let widget = targetEl.parentElement;
320                        if( typeof widget !== 'undefined' &&
321                            widget !== null ) {
322                            if( widget.classList.contains('collapsed') ) {
323                                closeAllFooterWidgets();
324                                widget.classList.remove('collapsed');
325                            } else {
326                                closeAllFooterWidgets();
327                                widget.classList.add('collapsed')
328                            }
329                        }
330                    }
331                });
332            }
333
334        });
335    }
336
337    function closeAllFooterWidgets() {
338        document.querySelectorAll("#footer-outer .col .widget").forEach( function(item) {
339            item.classList.add("collapsed");
340        });
341    }
342    /*MAKING FOOTER NAVIGATION MENU WIDGETS TO ACCORDIONS ON MOBILE*/
343
344
345    /*AVOIDING PAGE SCROLL/JUMP WHILE CLICKING ON ANCHOR TAG WITH HASH*/
346    let InnerPageOffersAnchor = Array.prototype.slice.call(document.querySelectorAll(".innerpage-offers__anchor"), 0);
347    if( typeof InnerPageOffersAnchor !== 'undefined' &&
348        InnerPageOffersAnchor != null &&
349        InnerPageOffersAnchor.length > 0 )
350    {
351        InnerPageOffersAnchor.forEach( function(item) {
352            item.addEventListener("click", function(e) {
353                if( item.href.match(/#/gi) ) {
354                    e.preventDefault();
355                }
356            });
357        });
358    }
359    /*AVOID PAGE SCROLL/JUMP WHILE CLICKING ON ANCHOR TAG WITH HASH*/
360/* }); */
361
362/* document.addEventListener('DOMContentLoaded', function(event) { */
363
364    /*STICKY BUTTONS HIDE AND SHOW*/
365    let stickyButtonsMenu = document.getElementsByClassName('sticky-buttons__menu');
366    if( typeof stickyButtonsMenu[0] !== 'undefined' &&
367        stickyButtonsMenu[0] != null ) {
368        showStickyButtonsOnScroll();
369        initialStickyButtonCheck();
370        let stickyHideButton = document.getElementById("sticky_button_hide");
371        if (typeof stickyHideButton !== 'undefined' && stickyHideButton != null) {
372            stickyHideButton.addEventListener("click",
373                function (event) {
374                    event.preventDefault();
375                    checkAndUpdateStickyCookieValue();
376                });
377        }
378
379        let stickyShowButton = document.getElementById("sticky_button_show");
380        if (typeof stickyShowButton !== 'undefined' && stickyShowButton !== null) {
381            stickyShowButton.addEventListener("click",
382                function (event) {
383                    event.preventDefault();
384                    checkAndUpdateStickyCookieValue();
385                });
386        }
387    }
388    /*STICKY BUTTONS HIDE AND SHOW*/
389
390/* }); */
391
392function updateRequestFormatDropdown(e) {
393    var downloadIndex = null;
394    var PostIndex = null;
395    if(typeof document.querySelector('.request_format select') !== 'undefined' && document.querySelector('.request_format select') != null) {
396        var downloadPostSelectDropdownEl = document.getElementById(document.querySelector('.request_format select').id);
397        if (downloadPostSelectDropdownEl.options[0].value.match(/download/gi)) {
398            downloadIndex = 0;
399            PostIndex = 1;
400        }
401        if (typeof downloadPostSelectDropdownEl !== 'undefined' || downloadPostSelectDropdownEl != null) {
402            if (e.target.classList.contains('by-post')) {
403                document.getElementById(downloadPostSelectDropdownEl.id).selectedIndex = PostIndex;
404                // console.log('clicked post!');
405            } else {
406                document.getElementById(downloadPostSelectDropdownEl.id).selectedIndex = downloadIndex;
407                // console.log('clicked download!');
408            }
409        }
410    }
411
412}

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.