1(function($) { 2 $(function() { 3 var cu = cu || {}; 4 5 cu.isContactOpen = false; 6 cu.isCartOpen = false; 7 cu.isAccountOpen = false; 8 9 // Contact 10 cu.hideContact = function () { 11 cu.isContactOpen = false; 12 $('ul.header-top-menu').removeClass('show'); 13 $('ul.header-top-menu').off('mouseleave'); 14 } 15 16 cu.showContact = function () { 17 cu.isContactOpen = true; 18 $('ul.header-top-menu').addClass('show'); 19 $('ul.header-top-menu').mouseleave(cu.contactOut); 20 } 21 22 cu.contactOver = function () { 23 if (cu.isContactOpen === true) { 24 return; 25 } 26 27 cu.showContact(); 28 } 29 30 cu.contactOut = function () { 31 if ($('ul.header-top-menu:hover').length == 0 32 && $('.menu-contact:hover').length == 0) { 33 cu.hideContact(); 34 } 35 } 36 37 $('.menu-contact').hover(cu.contactOver, cu.contactOut); 38 39 // Account 40 cu.hideAccount = function () { 41 cu.isAccountOpen = false; 42 $('ul.header-top-account').removeClass('show'); 43 $('ul.header-top-account').off('mouseleave'); 44 } 45 46 cu.showAccount = function () { 47 cu.isAccountOpen = true; 48 $('ul.header-top-account').addClass('show'); 49 $('ul.header-top-account').mouseleave(cu.accountOut); 50 } 51 52 cu.accountOver = function () { 53 if (cu.isAccountOpen === true) { 54 return; 55 } 56 57 cu.showAccount(); 58 } 59 60 cu.accountOut = function () { 61 if ($('ul.header-top-account:hover').length == 0 62 && $('.menu-account:hover').length == 0) { 63 cu.hideAccount(); 64 } 65 } 66 67 $('.menu-account').hover(cu.accountOver, cu.accountOut); 68 69 // Cart 70 cu.hideCart = function () { 71 cu.isCartOpen = false; 72 $('.header-top-cart').removeClass('show'); 73 $('.header-top-cart').off('mouseleave'); 74 } 75 76 cu.showCart = function () { 77 cu.isCartOpen = true; 78 $('.header-top-cart').addClass('show'); 79 $('.header-top-cart').mouseleave(cu.cartOut); 80 } 81 82 cu.cartOver = function () { 83 if (cu.isCartOpen === true) { 84 return; 85 } 86 87 cu.showCart(); 88 } 89 90 cu.cartOut = function () { 91 if ($('.header-top-cart:hover').length == 0 92 && $('.header-cart:hover').length == 0) { 93 cu.hideCart(); 94 } 95 } 96 97 $('.header-cart').hover(cu.cartOver, cu.cartOut); 98 99 // Initialise bootstrap-multiselect 100 $('#search-bar-select').multiselect({ 101 includeSelectAllOption: false, 102 buttonText: function(options, select) { 103 return ''; 104 }, 105 onChange: function(option, checked, select) { 106 var selectedOptions = $('#search-bar-select option:selected'); 107 var options = []; 108 selectedOptions.each(function() { 109 options.push($(this).text().toLowerCase()); 110 }); 111 if(options){ 112 $('#search-bar-input').attr('placeholder', 'Search ' + options.join(', ')); 113 } 114 } 115 }); 116 117 // Map facets to urls for contextual initial search selection 118 var map = { 119 'Products': ['/product', '/products', '/donations/content'], 120 'Upcoming webinars': ['/webinars/upcoming'], 121 'Past webinars': ['/webinars/past'], 122 'Case Studies': ['/case-studies', '/case-study'], 123 'Blogs': ['/blog'], 124 'Other': ['/directory/suppliers'] 125 }; 126 for(var key in map) { 127 for(let index = 0; index < map[key].length; ++index) { 128 if(window.location.pathname.toLowerCase().startsWith(map[key][index])){ 129 $('#search-bar-select').multiselect('select', 'custom_content_type:' + key, true); // Third param triggers onChange 130 } 131 } 132 } 133 if(window.location.pathname.toLowerCase().startsWith('/search')){ 134 const paramsString = window.location.search; 135 let searchParams = new URLSearchParams(paramsString); 136 if(searchParams.has('f[]')){ 137 let searchTypes = searchParams.getAll('f[]'); 138 for(let s of searchTypes){ 139 $('#search-bar-select').multiselect('select', s, true); // Third param triggers onChange 140 } 141 } 142 } 143 144 // Mobile menu 145 cu.menuSpeed = 300; 146 147 cu.handleMenuClick = function (e) { 148 e.stopPropagation(); 149 150 var $parentMenu = $(e.target).closest('ul.menu-container'), 151 $rootMenu = $('ul.menu-container.root'), 152 $childMenu = $(e.target).find('ul.menu-container').first(), 153 depth = ($childMenu.attr('data-menu-depth')) - 1; 154 155 $childMenu.css('display', 'block'); 156 $rootMenu.animate({left: (-depth * 100) + '%'}, cu.menuSpeed); 157 } 158 159 cu.handleBackClick = function (e) { 160 e.stopPropagation(); 161 162 var $thisMenu = $(e.target).closest('ul.menu-container'), 163 $rootMenu = $('ul.menu-container.root') 164 depth = $thisMenu.attr('data-menu-depth'); 165 166 $rootMenu.animate({left: (100 - (depth - 1) * 100) + '%'}, cu.menuSpeed, function () { 167 $thisMenu.css('display', 'none'); 168 }); 169 } 170 171 // Menu expand links 172 $('div.mobile-menu li.expanded').each(function () { 173 var title = $(this).attr('data-title'); 174 $(this).find('span').first().html(title).click(cu.handleBackClick); 175 176 $(this).click(cu.handleMenuClick); 177 }); 178 179 // Other menu links 180 $('div.mobile-menu li.leaf').each(function () { 181 $(this).click(function (e) { 182 e.stopPropagation(); 183 184 window.location = $(this).find('a').attr('href'); 185 }); 186 }); 187 188 // Close / open button 189 cu.isMobileOpen = false;
190 $('.nav-mobile .button.hamburger').click(function () { 191 var xOffset = $(window).width() - 64; 192 $(this).find('.hamburger').toggleClass('hide'); 193 $(this).find('.cross').toggleClass('hide'); 194 195 if (!cu.isMobileOpen) { 196 $('.site-wrapper').toggleClass('mobile-open'); 197 $('div.mobile-menu').animate({left: 0}, cu.menuSpeed); 198 199 $('.site-wrapper').animate({left: xOffset + 'px'}, cu.menuSpeed); 200 } 201 202 if (cu.isMobileOpen) { 203 $('div.mobile-menu').animate({left: -xOffset + 'px'}, cu.menuSpeed); 204 $('.site-wrapper').animate({left: 0}, cu.menuSpeed, function () { 205 $('.site-wrapper').toggleClass('mobile-open'); 206 }); 207 } 208 209 cu.isMobileOpen = !cu.isMobileOpen; 210 }); 211 }); 212})(jQuery);
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.