1/** 2 * File scipts.js. 3 */ 4 5jQuery(document).ready(function($) { 6 7 // Add Bootstrap dropdown classes to nested menu items 8 let menuItemHasChildren = document.querySelectorAll('.navbar .menu-item-has-children:not(.bcb-mega-menu)'); 9 menuItemHasChildren.forEach(function(childItem) { 10 childItem.classList.add('dropdown'); 11 }); 12 13 // Add Bootstrap toggle classes to nested menu items 14 let menuItemHasChildrenAnchor = document.querySelectorAll('.navbar .menu-item-has-children:not(.bcb-mega-menu) > a'); 15 menuItemHasChildrenAnchor.forEach(function(childItemAnchor) { 16 childItemAnchor.classList.add('dropdown-toggle'); 17 }); 18 19 // Add animation class to dropdown menu 20 let addAnimationClasses = document.querySelectorAll('.navbar .dropdown-menu'); 21 addAnimationClasses.forEach(function(animationClasses) { 22 animationClasses.classList.add('sub-menu-animate' , 'slideUp'); 23 }); 24 25 // Add Bootstrap toggle classes to nested menu items 26 let sidebarCardUl = document.querySelectorAll('#sidebar .card ul, #sidebar .custom-html-widget'); 27 sidebarCardUl.forEach(function(ul) { 28 ul.outerHTML = `<div class="card-body">${ul.outerHTML}</div>`; 29 }); 30 31 // Change dropdown from click to hover, only for non mega-menus 32 let navbarDropdown = document.querySelectorAll('.navbar .dropdown:not(.bcb-mega-menu)'); 33 navbarDropdown.forEach(function(dropdown) { 34 dropdown.addEventListener('mouseenter', function( event ) { 35 dropdownMenu = this.querySelector('.dropdown-menu'); 36 dropdownMenu.style.display = 'block'; 37 38 }); 39 dropdown.addEventListener('mouseleave', function( event ) { 40 dropdownMenu = this.querySelector('.dropdown-menu'); 41 dropdownMenu.style.display = 'none'; 42 }); 43 }); 44 45 // Reposition Mega Menu Modals right under the corresponding .bcb-mega-menu links 46 let megaMenuItems = document.querySelectorAll('.navbar .bcb-mega-menu > a'); // This targets anchor tags within .bcb-mega-menu items. 47 megaMenuItems.forEach(function(menuLink) { 48 let modalId = 'bcb-menu-item-' + menuLink.parentNode.id.split("-")[2]; // parentNode refers to the .bcb-mega-menu element. 49 let modalElement = document.getElementById(modalId); 50 51 if (modalElement) { 52 // Insert the modal directly after the menu link 53 menuLink.insertAdjacentElement('afterend', modalElement); 54 } 55 }); 56 57 // Add Bootstrap pagination classes 58 let paginationIndex = document.querySelectorAll('.pagination a, .pagination span'); 59 paginationIndex.forEach(function(index) { 60 index.classList.add('page-link'); 61 }); 62 63 // Add class to body tag when user scrolls 64 let scrollPosition = window.scrollY; 65 let body = document.getElementsByTagName('body')[0]; 66 window.addEventListener('scroll', function() { 67 scrollPosition = window.scrollY; 68 69 if(scrollPosition >= 100) { 70 body.classList.add('scrolled'); 71 } else { 72 body.classList.remove('scrolled'); 73 } 74 }); 75 76 // Sticky Navbar 77 function stickyToggle(sticky, stickyWrapper) { 78 let stickyHeight = sticky.offsetHeight; 79 let stickyTop = stickyWrapper.offsetTop; 80 let scrollPosition = window.scrollY || window.pageYOffset; 81 82 if (scrollPosition >= stickyTop) { 83 stickyWrapper.style.height = `${stickyHeight}px`; 84 sticky.classList.add('fixed-top'); 85 86 // Check if the #wpadminbar is present and adjust the top of .fixed-top 87 if (document.getElementById('wpadminbar')) { 88 sticky.style.top = '32px'; 89 } else { 90 sticky.style.top = '0px'; // Default to 0 if no admin bar 91 } 92 } else { 93 sticky.classList.remove('fixed-top'); 94 stickyWrapper.style.height = 'auto'; 95 } 96 } 97 98 // Apply sticky behavior to every element with the class '.fixed-top' 99 let classOfFixedTops = document.querySelectorAll('.fixed-top'); 100 101 classOfFixedTops.forEach(function(element) { 102 let stickyWrapper = document.createElement('div'); 103 stickyWrapper.className = 'sticky-wrapper'; 104 105 element.parentNode.insertBefore(stickyWrapper, element); 106 stickyWrapper.appendChild(element); 107 108 // On page load 109 stickyToggle(element, stickyWrapper); 110 111 // If you want to update the sticky behavior on scroll: 112 window.addEventListener('scroll', function() { 113 stickyToggle(element, stickyWrapper); 114 }); 115 }); 116 117 // Modal Popup 118 119 // Cookie name 120 let bcbCookieName = 'bcbPopup'; 121 122 // Set cookie expiry time 123 let bcbCookieLifetime = 1; 124 125 // Set cookie 126 let _setCookie = function (cname, cvalue, exdays) { 127 let d = new Date(); 128 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); 129 let expires = "expires=" + d.toUTCString(); 130 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 131 }; 132 133 // Get cookie 134 let _getCookie = function (cname) { 135 let name = cname + "="; 136 let ca = document.cookie.split(';'); 137 for (let i = 0; i < ca.length; i++) { 138 let c = ca[i]; 139 while (c.charAt(0) == ' ') { 140 c = c.substring(1); 141 } 142 if (c.indexOf(name) == 0) { 143 return c.substring(name.length, c.length); 144 } 145 } 146 return ""; 147 }; 148 149 // Should the cookie popup be shown? 150 let _shouldShowPopup = function () { 151 if (_getCookie(bcbCookieName)) { 152 return false;
153 } else { 154 return true; 155 } 156 }; 157 158 let bcbPopup = document.getElementById('bcb-popup'); 159 160 // Show the cookie popup on load 161 if (_shouldShowPopup()) { 162 setTimeout(function() { 163 jQuery('#bcb-popup').modal('show'); 164 }, 3000) 165 } 166 167 // Modal dismiss 168 if(bcbPopup) { 169 bcbPopup.addEventListener('hidden.bs.modal', event => { 170 _setCookie(bcbCookieName, 1, bcbCookieLifetime); 171 }); 172 } 173 174});
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.