PageSourceSearch

https://www.ushorizon.com/_ui/responsive/common/js/crl.headernav.js

js ushorizon.com collected 2026-10-06 02:04:56 UTC 9,667 bytes, 221 lines download raw bytes

1ACC.HeaderNav = {
2    _autoload: ["setEventHandlers"],
3    setEventHandlers: function() {
4        const topNav = document.getElementsByClassName("top-nav")[0];
5        const mainNav = document.getElementsByClassName("navigation")[0];
6        const header = document.getElementsByClassName("header")[0];
7        const purchaser = document.getElementsByClassName("purchaser-link")[0];
8        const specifier = document.getElementsByClassName("specifier-link")[0];
9        const profileValue = document.getElementById("customer-profile") ? document.getElementById("customer-profile").value : null;
10        const navbarUserBtn = document.getElementsByClassName("j-user-navbar") ? document.getElementsByClassName("j-user-navbar")[0] : null;
11        const navbarCartBtn = document.getElementsByClassName("j-cart-navbar") ? document.getElementsByClassName("j-cart-navbar") : null;
12        const navbarAcctBtn = document.getElementsByClassName("j-account-navbar") ? document.getElementsByClassName("j-account-navbar") : null;
13        const logoutBtn = document.getElementsByClassName("j-logout-btn") ? document.getElementsByClassName("j-logout-btn") : null;
14        const commonMethods = new ACC.CRLCommon.GetMethods();
15		
16		$(document).ready(function() {
17			
18			$("select#countrySelection").change(function() {
19				let href = $(this)?.val();
20				var win = window.open(href, '_self');
21				if(win) {
22					win.focus();
23				}
24				else {
25					alert("Please allow popups for this website");
26				}
27				$(this)[0].selectedIndex = 0;
28			});
29			
30		    $('#countrySelection').on('change', function() {
31		      window.open(this.value, '_self');;
32		    });
33		});
34		
35        $(document).ready(
36            setTimeout(()=> {
37                setProfile();
38
39                if(logoutBtn) {
40                    const buttons = [...logoutBtn];
41
42                    buttons.forEach(btn => {
43                        btn.addEventListener('click', (event) => {
44                            commonMethods.RedirectLogout();
45                        });
46                    });
47                }
48
49				let isExperiencePopupClosedOnce = false;
50                let getAllCookies = document.cookie.split(";");
51                console.log("getAllCookies : ",getAllCookies);
52                
53                isExperiencePopupClosedOnce = getAllCookies.includes(' experienceBoxClosedOnce=true') 
54                								|| getAllCookies.includes('experienceBoxClosedOnce=true') 
55                								|| getAllCookies.includes('experienceBoxClosedOnce=true ') 
56                								|| getAllCookies.includes(' experienceBoxClosedOnce=true ');
57				
58				if($(".top-nav__profile--text--selected") && $(".top-nav__profile--text--selected")[0]) {
59					const getSelectedExperience = $(".top-nav__profile--text--selected")[0].innerText;
60					if(getSelectedExperience.toLowerCase() == "specify") {
61						if($("body") && $("body")[0]) {
62							$("body")[0].classList.add('selected-specifier');
63							$("body")[0].classList.remove('selected-purchaser');
64						}
65					}else {
66						
67						if($("body") && $("body")[0]) {
68							$("body")[0].classList.remove('selected-specifier');
69							$("body")[0].classList.add('selected-purchaser');
70						}
71					}
72					//For Desktop
73					if($(".experience-box") && $(".experience-box")[0]) {
74						$(".experience-box")[0].classList.add("hide-experience-box");
75						$(".experience-box")[0].classList.remove("show-experience-box");
76						
77						//this is to remove the background when popup is not there
78						if($(".carousel-inner .container") && $(".carousel-inner .container")[0]) $(".carousel-inner .container")[0].classList.remove("experience-box-background");
79					}
80					console.log('$(".experience-box") : ',$(".experience-box"));
81					// For Mobile
82					if($(".experience-box") && $(".experience-box")[1]) {
83						$(".experience-box")[1].classList.add("hide-experience-box");
84						$(".experience-box")[1].classList.remove("show-experience-box");
85						
86						//this is to remove the background when popup is not there
87						if($(".carousel-inner .container") && $(".carousel-inner .container")[1]) $(".carousel-inner .container")[1].classList.remove("experience-box-background");
88					}
89				} else {
90					console.log('else : ',$(".experience-box"));
91					//For Desktop
92					//third condition is to check if the exp box is closed once, popup shown not appear once closed until reopen in new window
93					if($(".experience-box") && $(".experience-box").length>0 && !isExperiencePopupClosedOnce) {
94						console.log("if enter");
95						const experienceBox = $(".experience-box");
96						experienceBox.map((x , expBox) => {
97							expBox.classList.add("show-experience-box");
98							expBox.classList.remove("hide-experience-box");
99							
100							//this is to add a grey background for the popup shown
101							if($(".carousel-inner .container") && $(".carousel-inner .container").length>0) {
102								const expBackground = $(".carousel-inner .container");
103								expBackground.map((y , ele) => {
104									ele.classList.add("experience-box-background");
105								});
106							}
107						});
108					}
109				}
110            },1000)
111        );
112
113        function setProfile() {
114            if(profileValue === "purchaser") {
115                sessionStorage.removeItem("crlExperience");
116            }
117
118            if(ACC.config.CSRFToken)
119                sessionStorage.setItem("csrftoken",ACC.config.CSRFToken);
120
121            const crlExperience = sessionStorage.getItem('crlExperience');
122            
123            if(crlExperience === 'specifier' && !profileValue) {
124                const params = new URLSearchParams(window.location.search);
125                if(!params.has("profile")) {
126                    const url = setlocalUrl('?profile=specifier');
127                    window.location.href = url;
128                }
129            }
130
131            if((crlExperience === "specifier" || profileValue === "specifier") && undefined != specifier)
132                specifier.className="top-nav__profile--text specifier-link top-nav__profile--text--selected";
133            if(profileValue === "purchaser" && undefined != purchaser)
134                purchaser.className="top-nav__profile--text purchaser-link top-nav__profile--text--selected";
135        }
136
137        let prevScrollpos = window.pageYOffset;
138        let prevHeaderClasses = '';
139        window.onscroll = () => {
140            if(prevScrollpos < window.pageYOffset && window.pageYOffset >= 34) {
141                topNav.className = "top-nav top-nav--closed";
142                mainNav.className = "navigation navigation--closed";
143                header.className  ="header header--closed";
144            } else {
145                topNav.className = "top-nav";
146                mainNav.className = "navigation";
147                header.className  ="header";
148            }
149            if (header.className != prevHeaderClasses) {
150                prevHeaderClasses = header.className;
151                // header.dispatchEvent(headerEvent);
152                window.setTimeout(function(){
153                    header.dispatchEvent(new CustomEvent('header-resized', { bubbles: true, detail: { height: header.clientHeight, rect: header.getBoundingClientRect() } }))
154                }, 100);
155                window.setTimeout(function(){
156                    header.dispatchEvent(new CustomEvent('header-resized', { bubbles: true, detail: { height: header.clientHeight, rect: header.getBoundingClientRect() } }))
157                }, 200);
158                window.setTimeout(function(){
159                    header.dispatchEvent(new CustomEvent('header-resized', { bubbles: true, detail: { height: header.clientHeight, rect: header.getBoundingClientRect() } }))
160                }, 310);
161            }
162        }
163
164        if(purchaser) {
165            purchaser.addEventListener('click',(event) => {
166                const currentProfile = sessionStorage.getItem('crlExperience');
167                sessionStorage.removeItem('crlExperience');
168                sessionStorage.removeItem('crl-specifier-email');
169                if(currentProfile === 'specifier' || profileValue === 'specifier') {
170                    commonMethods.RedirectLogout();
171                } else {
172                    commonMethods.RedirectLogin();
173                }
174            });
175        }
176
177        if(specifier) {
178            specifier.addEventListener('click',(event) => {
179                if(profileValue === 'purchaser') {
180                    sessionStorage.removeItem('crlExperience');
181                    commonMethods.RedirectLogout();
182                } else {
183                    commonMethods.RedirectLogin();
184                }
185            });
186        }
187
188        const setlocalUrl = (path) => {
189				return ACC.config.encodedContextPath + `/${path}`;
190        }
191
192        if(navbarUserBtn) {
193            navbarUserBtn.addEventListener('click', (event) => {
194                commonMethods.RedirectLogin();
195            });
196        }
197
198        if(navbarCartBtn) {
199            const buttons = [...navbarCartBtn];
200            buttons.forEach(btn => {
201                btn.addEventListener('click', (event) => {
202					var ifSiteIsUSH = document.body.classList.contains("site-ush");
203					if(ifSiteIsUSH){
204                    window.location.href = setlocalUrl('cart');
205                    }
206                });
207            });
208        }
209
210        if(navbarAcctBtn) {
211            const buttons = [...navbarAcctBtn];
212
213            buttons.forEach(btn => {
214                btn.addEventListener('click', (event) => {
215	               	ACC.CRLMyAccountDashboard.displayCrlPageLoader();
216                    window.location.href = setlocalUrl('accountdashboard');
217                });
218            });
219        }
220    }
221}

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.