1function escapeHtml(str) { 2 if (str == null) return ''; 3 return String(str) 4 .replace(/&/g, '&') 5 .replace(/</g, '<') 6 .replace(/>/g, '>') 7 .replace(/"/g, '"') 8 .replace(/'/g, '''); 9} 10 11function sanitizeUrl(url) { 12 if (!url) return '#'; 13 var trimmed = String(url).trim().toLowerCase().replace(/[\u0000-\u001f]/g, ''); 14 if (trimmed.indexOf('javascript:') === 0 || trimmed.indexOf('data:') === 0 || trimmed.indexOf('vbscript:') === 0) { 15 return '#'; 16 } 17 return url; 18} 19 20function escapeRegExp(str) { 21 return String(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); 22} 23 24$(document).ready(function () { 25 26 27$(".cancelicon").on('click', (function () { 28 if ($("#fundsearchterm").length) { 29 document.getElementById("fundsearchterm").value=''; 30 } 31 $("#predicateCancel").css("display","none"); 32 33 $("#predicateGo").css("display","none"); 34 })); 35 36 37 $(".homepage-hero .goicon").on('click', (function () { 38 var searchDis; 39 40 searchDis = $('#fundsearchterm').val(); 41 42 keyword = searchDis; 43 44 var searchInput = searchDis.toLowerCase(); 45 46 if (searchInput !== '') { 47 window.location = "/content/thf/en/funds" + ".html?fundkeyword=" + encodeURIComponent(keyword); 48 } 49 50 })); 51 52 $("#fundsearchterm").keypress(function (e) { 53 54 if (e.which == 13) { 55 56 var searchDis = $(this).val(); 57 keyword = searchDis; 58 var searchInput = searchDis.toLowerCase(); 59 if (searchInput !== '') { 60 window.location = "/content/thf/en/funds" + ".html?fundkeyword=" + encodeURIComponent(keyword); 61 } 62 } 63 64 65 }); 66 67 $("#fundsearchterm").keydown(function (e) { 68 69 70 if (e.which == 8) { 71 72 73 74 if ($("#fundsearchterm").length) { 75 76 77 $("#predicateCancel").css("display","none"); 78 79 $("#predicateGo").css("display","none"); 80 81 82 } 83 } 84 85 86 }); 87 88 }); 89 90function dummySearch(){ 91 92 93 if ($("#fundsearchterm").val().length > 1) { 94 95 96 $("#predicateCancel").css("display","block"); 97 98 $("#predicateGo").css("display","block"); 99 100 homepageSearch(); 101 }else{ 102 $("#predicateCancel").css("display","none"); 103 104 $("#predicateGo").css("display","none"); 105 } 106 107} 108 109function homepageSearch() { 110 111 var totalResults; 112 var nonfdpflag; 113 114 115 $("#fundsearchterm").autocomplete({ 116 source: function (request, response) { 117 var keyword = $("#fundsearchterm").val(); 118 119 if ($("#fundsearchterm").val().length > 1) { 120 121 if ($.trim(keyword) != '') { 122 $.getJSON('/bin/thf/servlets/fundlist.json?keyword=' + keyword, { 123 q: request.term 124 }, function (data) { 125 126 totalResults=data.totalResults; 127 nonfdpflag=data.nonfdp; 128 129 130 131 response($.map(data.fundList, function (item) { 132 133 return item; 134 })); 135 }); 136 } 137 } 138 }, 139 appendTo: ".searchbar", 140 minLength: 1, 141 select: function (event, ui) { 142 if (ui.item.fundlink != '#') { 143 // AutoSuggestClick('Funds', ui.item.fundname); Commented for siteCatalyst Code clean up 144 145 $('#fundsearchterm').val(ui.item.fundname); 146 window.open(ui.item.fundlink, '_self'); 147 return false; 148 } else { 149 return false; 150 } 151 }, 152 153 open: function (response) { 154 155 $("input.fundFinderBtn").addClass('goPredictive'); 156 157 if(totalResults !='undefined' && totalResults!='0' && totalResults !=undefined && totalResults!=0){ 158 159 var keywrd=$("#fundsearchterm").val(); 160 var encodedKeywrd = encodeURIComponent(keywrd); 161 162 if(!nonfdpflag){ 163 var safeTotal = parseInt(totalResults, 10) || 0; 164 $('<li class="ui-menu-item see-all-results">'+safeTotal+' total results found <a href="/funds.html?fundkeyword='+encodedKeywrd+'#Performance">SEE ALL RESULTS</a></li>') 165 .on('click', function(event) {$("#dialog-add-new").dialog("open");}) 166 .appendTo('ul.ui-autocomplete'); 167 } 168 } 169 170 }, 171 close: function () { 172 $("input.fundFinderBtn").removeClass('goPredictive'); 173 } 174 }).data("ui-autocomplete")._renderItem = function (ul, item) { 175 var keywrd=$("#fundsearchterm").val(); 176 if (item.fundlink != '#') { 177 var matchText=""; 178 if((item.fundname).toLowerCase().indexOf(this.term.toLowerCase().replace(" ","")) !==-1){ 179 matchText=this.term.replace(" ",""); 180 }else{ 181 matchText=this.term; 182 } 183 var escapedFundName = escapeHtml(item.fundname); 184 var newText = escapedFundName.replace(new RegExp(escapeRegExp(matchText), 'gi'), "<span class='ui-state-highlight'>$&</span>"); 185 return $('<li></li>').data('item.autocomplete', item).append($('<a></a>').attr('href', sanitizeUrl(item.fundlink)).html(escapeHtml(item.productType) + "<div class=\"predicateTitle\">" + newText + "</div>")).appendTo('ul.ui-autocomplete'); 186 } else { 187 return $("<li></li>").data("item.autocomplete", item).append($("<div></div>").html("No funds match your search. Would you like to <a href='/searchResult.html?keyword="+encodeURIComponent(keywrd)+"'>search the full site instead?</a>")).appendTo('ul.ui-autocomplete'); 188 } 189 190 }; 191 //if(ui.item.totalResults !=) 192 193 194 195 $(".fundFinderBtn").click(function () { 196 var fundName = $("div.fundFinder ul.ui-autocomplete li:first-child a").html(); 197 var fundPageUrl = $("div.fundFinder ul.ui-autocomplete li:first-child a").attr("href"); 198 var searchText = $(".fundFinderSearch").val(); 199 if ($('div.fundFinder ul.ui-autocomplete').is(':visible') && fundName != null && fundPageUrl != null && $.trim(searchText) != '') { 200 window.open(fundPageUrl, '_self'); 201 } 202 $(this).val("Name, Symbol or CUSIP"); 203 }); 204 205 $('input.fundFinderSearch').keyup(function (e) { 206 if (e.keyCode == 13) { 207 var fundName = $("div.fundFinder ul.ui-autocomplete li:first-child a").html(); 208 var fundPageUrl = $("div.fundFinder ul.ui-autocomplete li:first-child a").attr("href"); 209 var searchText = $(".fundFinderSearch").val(); 210 if ($('div.fundFinder ul.ui-autocomplete').is(':visible') && fundName != null && fundPageUrl != null && $.trim(searchText) != '') { 211 window.open(fundPageUrl, '_self'); 212 } 213 214 } else { 215 $(".ui-autocomplete").scrollTop(0, 0); 216 } 217 }); 218 } 219 220function escapeHtml(str) { 221 if (str == null) return ''; 222 return String(str) 223 .replace(/&/g, '&') 224 .replace(/</g, '<') 225 .replace(/>/g, '>') 226 .replace(/"/g, '"') 227 .replace(/'/g, '''); 228} 229 230function sanitizeUrl(url) { 231 if (!url) return '#'; 232 var trimmed = String(url).trim().toLowerCase().replace(/[\u0000-\u001f]/g, ''); 233 if (trimmed.indexOf('javascript:') === 0 || trimmed.indexOf('data:') === 0 || trimmed.indexOf('vbscript:') === 0) { 234 return '#'; 235 } 236 return url; 237} 238 239$(document).ready(function() { 240 $(".mainnavcancelicon").on('click', (function() { 241 document.getElementById("glbl-home-search").value = ''; 242 $('.globalhomesearchbar .ui-widget-content').empty(); 243 $('.globalhomesearchbar .ui-widget').css('height', 'auto'); 244 })); 245 246 $(".mainnavgoicon").on('click', (function() { 247 var searchDis; 248 searchDis = $('#glbl-home-search').val(); 249 keyword = searchDis; 250 if (searchDis !== '') { 251 var starCharacter = searchDis.indexOf('*'); 252 var dotCharacter = searchDis.indexOf('.'); 253 var errorText = ''; 254 var errorText = searchFieldValidation(searchDis); 255 if ($('#sresult ul div').html()) { 256 $('#sresult ul div').remove(); 257 } 258 if (errorText !== '') { 259 $('#sresult ul').append(errorText); 260 } else { 261 if ($('#glbl-home-search').val().length <= 2) { 262 $('#sresult ul').append(errorText); 263 } else { 264 window.location = "/searchResult" + ".html?keyword=" + encodeURIComponent(keyword); 265 } 266 } 267 } 268 })); 269 270 window.addEventListener("keydown", function(e){ 271 if(e.keyCode === '8' && e.key === 'Backspace'){ 272 globalHomeSearch(); 273 } 274 }); 275}); 276 277(function() { 278 window.onpageshow = function(event) { 279 //IOS devices 280 if (event.persisted) { 281 document.getElementById("glbl-home-search").value = ''; 282 $('.globalhomesearchbar .ui-widget-content').empty(); 283 $('.globalhomesearchbar .ui-widget').css('height', 'auto'); 284 } 285 }; 286})(); 287 288function globalHomeSearch() { 289 setTimeout(function(){ 290 var searchDis; 291 searchDis = $('#glbl-home-search').val(); 292 if (searchDis !== '') { 293 var errorMessage = searchFieldValidation(searchDis); 294 if ($('#sresult ul div').html()) { 295 $('#sresult ul div').remove(); 296 } 297 if (errorMessage !== '') { 298 $('#sresult ul').append(errorMessage); 299 } else { 300 if ($("#glbl-home-search").val().length <= 2) { 301 $("#predicateCancel").css("display", "none"); 302 $("#predicateGo").css("display", "none"); 303 $('#sresult ul').append(errorMessage); 304 } else { 305 homepageGlobalSearch(); 306 } 307 } 308 } 309 }, 10); 310} 311 312/** 313*This function is to validate the searched keyword and show user-friendly error message. 314*/ 315function searchFieldValidation(searchInputVal) { 316 var firstInvalidCharacter = searchInputVal.indexOf('*');
317 var secondInvalidCharacter = searchInputVal.indexOf('.'); 318 var errorMessage=''; 319 if (firstInvalidCharacter !== -1 && secondInvalidCharacter !== -1) { 320 errorMessage = "<div class='validatedErrorSign'><span class='validatedErrorMessage'>Please remove - '.' & '*' from search.</span></div>"; 321 } else if((firstInvalidCharacter === -1 && secondInvalidCharacter !== -1) || (firstInvalidCharacter !== -1 && secondInvalidCharacter === -1)) { 322 if (firstInvalidCharacter === -1) { 323 errorMessage = "<div class='validatedErrorSign'><span class='validatedErrorMessage'>Please remove - '.' from search.</span></div>"; 324 } else { 325 errorMessage = "<div class='validatedErrorSign'><span class='validatedErrorMessage'>Please remove - '*' from search.</span></div>"; 326 } 327 } else if (searchInputVal.length <= 2) { 328 errorMessage = "<div class='validatedErrorSign'><span class='validatedErrorMessage'>Please provide a minimum of 3 characters to search.</span></div>"; 329 } 330 return errorMessage; 331} 332 333function homepageGlobalSearch() { 334 var totalResults; 335 let currentIndex = 0; 336 var productFlag, insightsFlag, pracMangFlag, literatureFlag, formsFlag, otherFlag, noResultFlag, singleCategoryFlag = false; 337 var productCount = 0; 338 var insightsCount = 0; 339 var pracMangCount = 0; 340 var literatureCount = 0; 341 var formsCount = 0; 342 var otherCount = 0; 343 var productEndCount = 0; 344 var insightsEndCount = 0; 345 var pracMangEndCount = 0; 346 var literatureEndCount = 0; 347 var formsEndCount = 0; 348 var otherEndCount = 0; 349 var isMobile = window.matchMedia("only screen and (max-width: 960px)").matches; 350 $("#glbl-home-search").autocomplete({ 351 source: function(request, response) { 352 var keyword = $("#glbl-home-search").val(); 353 var errorMessage= searchFieldValidation(keyword); 354 if ($('#sresult ul div').html()) { 355 $('#sresult ul div').remove(); 356 } 357 if (errorMessage !=='') { 358 if($('.globalhomesearchbar ul.ui-autocomplete').html()){ 359 $('.globalhomesearchbar ul.ui-autocomplete').hide(); 360 } 361 $('#sresult ul').append(errorMessage); 362 } else { 363 if ($("#glbl-home-search").val().length > 2) { 364 if ($.trim(keyword) != '' && $("#glbl-home-search").val().length > 2) { 365 $.getJSON('/bin/thf/servlets/globalPredictiveSearch.json?keyword=' + keyword, { 366 q: request.term 367 }, function(data) { 368 totalResults = data.gsResultsListSize; 369 singleCategoryFlag = data.gsSingleArrayCount; 370 if (isMobile) { 371 response($.map(data.gsOverAllmobileList, function(item) { 372 return item; 373 })); 374 } else { 375 response($.map(data.gsOverAllList, function(item) { 376 return item; 377 })); 378 } 379 }); 380 } 381 } 382 } 383 }, 384 appendTo: ".globalhomesearchbar", 385 minLength: 3, 386 select: function(event, ui) { 387 if (ui.item.itemLink != '#') { 388 //$('#glbl-home-search').val(ui.item.itemName); 389 //window.open(ui.item.itemLink, '_self'); 390 return false; 391 } else { 392 return false; 393 } 394 }, 395 open: function(response) { 396 if (totalResults != 'undefined' && totalResults != '0' && totalResults != undefined && totalResults != 0) { 397 var keywrd = $("#glbl-home-search").val(); 398 var encodedKeywrd = encodeURIComponent(keywrd); 399 var safeTotal = parseInt(totalResults, 10) || 0; 400 $('<li class="ui-menu-item see-all-results">' + safeTotal + ' total results found <a href="/searchResult.html?keyword=' + encodedKeywrd + '">SEE ALL RESULTS</a></li>') 401 .on('click', function(event) { 402 $("#dialog-add-new").dialog("open"); 403 }).appendTo('ul.ui-autocomplete'); 404 } 405 }, 406 close: function() { 407 $("input.fundFinderBtn").removeClass('goPredictive'); 408 } 409 }).data("ui-autocomplete")._renderItem = function(ul, item) { 410 var isMobile = window.matchMedia("only screen and (max-width: 960px)").matches; 411 var keywrd = $("#glbl-home-search").val(); 412 var categoryItemDI = ''; 413 var linkDI = ''; 414 var titleDI = ''; 415 var seperatorDI = '<hr class="separator">'; 416 var loggedIn; 417 var keywrd = $("#glbl-home-search").val(); 418 var encodedKeywrd = encodeURIComponent(keywrd); 419 if (document.getElementById('loggedInStatus')) { 420 loggedIn = document.getElementById('loggedInStatus').value; 421 } 422 if (totalResults != 0 && item.itemLink != 'NA') { 423 if (item.itemCategory == 'FUNDS') {
424 productEndCount = ++productEndCount; 425 } 426 if (item.itemCategory == 'INSIGHTS') { 427 insightsEndCount = ++insightsEndCount; 428 } 429 if (item.itemCategory == 'PRACTICE MANAGEMENT') { 430 pracMangEndCount = ++pracMangEndCount; 431 } 432 if (item.itemCategory == 'LITERATURE') { 433 literatureEndCount = ++literatureEndCount; 434 } 435 if (item.itemCategory == 'FORMS') { 436 formsEndCount = ++formsEndCount; 437 } 438 if (item.itemCategory == 'OTHERS') { 439 otherEndCount = ++otherEndCount; 440 } 441 if (!productFlag && item.itemCategory == 'FUNDS') { 442 productFlag = true; 443 productCount = ++productCount; 444 categoryItemDI = "<div class='clmn3head'>" + 'PRODUCTS' + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchGTMComplete()' class='homeSearch-seeAll' href='/funds.html?fundkeyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 445 446 } 447 if (!insightsFlag && item.itemCategory == 'INSIGHTS') { 448 insightsFlag = true; 449 insightsCount = ++insightsCount; 450 categoryItemDI = "<div class='clmn3head'>" + escapeHtml(item.itemCategory) + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchGTMComplete()' class='homeSearch-seeAll' href='/searchResult.html?search=mainNav&category=insights&keyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 451 452 } 453 if (!pracMangFlag && item.itemCategory == 'PRACTICE MANAGEMENT') { 454 pracMangFlag = true; 455 pracMangCount = ++pracMangCount; 456 categoryItemDI = "<div class='clmn3head'>" + escapeHtml(item.itemCategory) + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchGTMComplete()' class='homeSearch-seeAll' href='/searchResult.html?search=mainNav&category=practiceMgmnt&keyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 457 458 } 459 if (!literatureFlag && item.itemCategory == 'LITERATURE') { 460 literatureFlag = true; 461 literatureCount = ++literatureCount; 462 categoryItemDI = "<div class='clmn3head'>" + escapeHtml(item.itemCategory) + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchComplete()' class='homeSearch-seeAll' href='/searchResult.html?search=mainNav&category=literature&keyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 463 464 } 465 if (!formsFlag && item.itemCategory == 'FORMS') { 466 formsFlag = true; 467 formsCount = ++formsCount; 468 categoryItemDI = "<div class='clmn3head'>" + escapeHtml(item.itemCategory) + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchGTMComplete()' class='homeSearch-seeAll' href='/searchResult.html?search=mainNav&category=forms&keyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 469 470 } 471 if (!otherFlag && item.itemCategory == 'OTHERS') { 472 otherFlag = true; 473 otherCount = ++otherCount; 474 475 categoryItemDI = "<div class='clmn3head'>" + escapeHtml(item.itemCategory) + " (" + escapeHtml(item.itemCategorySize) + ") <span class='homeSearch-seeAll' id='homeSearch-seeAll'><a onclick='autoSearchGTMComplete()' class='homeSearch-seeAll' href='/searchResult.html?search=mainNav&category=others&keyword=" + encodedKeywrd + "' target='_blank'>SEE ALL</a></span></div>"; 476 477 } 478 if ((productCount + insightsCount + pracMangCount + literatureCount + formsCount + otherCount) > 3) { 479 $('.globalhomesearchbar .ui-widget').css('height', '450px'); 480 } else { 481 $('.globalhomesearchbar .ui-widget').css('height', 'auto'); 482 } 483 if (loggedIn == 'LoggedIn') { 484 linkDI = "<a onclick='autoSearchGTMComplete()' href=\"" + sanitizeUrl(item.itemLink) + "\" target=\"" + escapeHtml(item.itemLinkOpen) + "\" class='mainNavsearchlink'></a>"; 485 } else { 486 linkDI = "<a onclick='autoSearchGTMComplete()' href=\"" + sanitizeUrl(item.itemLink) + "\" target=\"" + escapeHtml(item.itemLinkOpen) + "\" class='loginOverlay osx'></a>"; 487 } 488 titleDI = "<div class=\"predicateTitle\">" + escapeHtml(item.itemName) + "</div>"; 489 if ((productEndCount == item.itemTotalSize || insightsEndCount == item.itemTotalSize || pracMangEndCount == item.itemTotalSize || literatureEndCount == item.itemTotalSize || formsEndCount == item.itemTotalSize || otherEndCount == item.itemTotalSize) && (item.itemCategory != 'OTHERS') && (item.itemTotalSize > 0) && (!singleCategoryFlag) && ((insightsCount + pracMangCount + literatureCount + formsCount + otherCount) > 1 || (productCount == 1) || (productCount == 0 && (insightsCount + pracMangCount + literatureCount + formsCount) >
489 0))) { 490 productEndCount = 0; 491 insightsEndCount = 0; 492 pracMangEndCount = 0; 493 literatureEndCount = 0; 494 formsEndCount = 0; 495 otherEndCount = 0; 496 return $("<li></li>").prepend(categoryItemDI).data("item.autocomplete", item).append($(linkDI).html(titleDI + seperatorDI)).appendTo('ul.ui-autocomplete'); 497 } else { 498 return $("<li></li>").prepend(categoryItemDI).data("item.autocomplete", item).append($(linkDI).html(titleDI)).appendTo('ul.ui-autocomplete'); 499 } 500 } else { 501 var noresultDI = ""; 502 if (totalResults == 0) { 503 if (!noResultFlag) { 504 noResultFlag = true; 505 var noresultDI = "No Results Found"; 506 $('.globalhomesearchbar .ui-widget').css('height', 'auto'); 507 } 508 } 509 return $("<li></li>").data("item.autocomplete", item).append($("<div class=\"noresults\"></div>").html(noresultDI)).appendTo('ul.ui-autocomplete'); 510 511 } 512 }; 513} 514$(document).ready(function () { 515 $('#exo_menu_mobile').click(function() { 516 if ($(this).hasClass("display")) { 517 $(".goicon").css('display','none'); 518 } 519 else{ 520 $(".goicon").css('display','block'); 521 } 522 }); 523 524 $(document).click(function (e) { 525 if(($(e.target).attr("id") == "mdsearch" || $(e.target).attr("id") == "search1") || $(e.target).attr("id") == "search"){ 526 if(!$(".mega-drop-down#search .mega-menu.globalhomesearchbar").is(':visible')){ 527 $("#search.mega-drop-down").toggleClass('globalhomesearchbar_dropshadow'); 528 $(this).find(".mega-drop-down#search .mega-menu.globalhomesearchbar").show(); 529 }else{ 530 if($(e.target).closest(".mega-menu.globalhomesearchbar").length <= 0){ 531 $("#search.mega-drop-down").toggleClass('globalhomesearchbar_dropshadow'); 532 $(this).find(".mega-drop-down#search .mega-menu.globalhomesearchbar").hide(); 533 }else{ 534 $(this).find(".mega-drop-down#search .mega-menu.globalhomesearchbar").show(); 535 } 536 } 537 }else{ 538 if($(".mega-drop-down#search .mega-menu.globalhomesearchbar").is(':visible') && $(e.target).closest(".mega-menu.globalhomesearchbar").length <= 0){ 539 $("#search.mega-drop-down").toggleClass('globalhomesearchbar_dropshadow'); 540 $(this).find(".mega-drop-down#search .mega-menu.globalhomesearchbar").hide(); 541 } 542 } 543 }); 544}); 545 546 547function moveSearch() { 548 if(window.innerWidth < 992) { 549 if($('div#mobile-search-placeholder li#search').length === 0) 550 $('div#mobile-search-placeholder').append($('ul#meganav li#search')); 551 } else { 552 if($('ul#meganav li#search').length === 0) 553 $('li#desktop-search-placeholder').after($('div#mobile-search-placeholder li#search')); 554 } 555} 556 557function moveUtilityNav() { 558 if(window.innerWidth < 992) { 559 if($('ul#meganav #utinav').length === 0) 560 $('ul#meganav').append($('header.header #utinav')); 561 }else{ 562 if($('header.header>#utinav').length === 0) 563 $('span#desktop-utinav-placeholder').after($('ul#meganav #utinav')); 564 } 565} 566 567function moveCartIcon() { 568 if(window.innerWidth < 992) { 569 if($('div#mobile-search-placeholder li#cart').length === 0) 570 $('div#mobile-search-placeholder').prepend($('ul#utinav li#cart')); 571 }else{ 572 if($('ul#utinav li#cart').length === 0) 573 $('ul#utinav').append($('div#mobile-search-placeholder li#cart')); 574 } 575} 576 577function closeMainNav() { 578 $('#meganav .show-nav-menu').each(function() { 579 var open = this; 580 $(open).addClass('fadeOut'); 581 setTimeout(function() { 582 $(open).removeClass('show-nav-menu'); 583 $(open).removeClass('show'); 584 $(open).parent().removeClass('dropshadow'); 585 }, 300); 586 }); 587} 588 589function openDropdown(ele, target) { 590 if(window.innerWidth >= 992) { 591 if($(ele).hasClass('dropshadow')) { 592 var openMenu = $(ele).find('.mega-menu'); 593 openMenu = openMenu[0]; 594 if(!openMenu.contains(target)) 595 closeDropdown(); 596 }else { 597 closeMainNav(); 598 closeDropdown(); 599 $(ele).addClass('dropshadow'); 600 $(ele).find('div.mega-menu').addClass('show-nav-menu'); 601 if($(ele).find('.utly-down-arrow')) { 602 $(ele).find('.utly-down-arrow').addClass('utly-up-arrow') 603 $(ele).find('.utly-down-arrow').removeClass('utly-down-arrow') 604 } 605 } 606 } 607} 608 609//close utility nav dropdown 610function closeDropdown() { 611 $("#utinav").find('.show-nav-menu').removeClass('show-nav-menu'); 612 $("#utinav").find('.dropshadow').removeClass('dropshadow'); 613 $('#utinav').find('.utly-up-arrow').toggleClass('utly-up-arrow utly-down-arrow') 614} 615 616$(function () { 617 moveSearch(); 618 moveUtilityNav(); 619 moveCartIcon(); 620 621 $(window).resize(function() { 622 moveSearch(); 623 moveUtilityNav(); 624 moveCartIcon(); 625 showMainNavSearchonHover(); 626 }); 627 628 $('.toggle-menu').click(function() { 629 $('.exo-menu').toggleClass('display'); 630 $('#prod').toggleClass('display'); 631 $('#meganav').toggleClass('bg-color'); 632 $(this).toggleClass('active'); 633 }); 634 635 $('#utinav li.mega-drop-down').click(function(e) { 636 openDropdown($(this), e.target); 637 if(window.innerWidth < 992) { 638 e.stopPropagation(); 639 } 640 }); 641 642 $('#meganav li.mega-drop-down').mouseover(function() { 643 if((window.innerWidth>=992)) { 644 var currenrSearchFlag=$(this).find('.mega-menu').hasClass('globalhomesearchbar'); 645 if(!currenrSearchFlag){ 646 closeDropdown(); 647 var dropdown = $('#utinav li.mega-drop-down.dropshadow'); 648 if (dropdown.length > 0) { 649 dropdown.find('[class*="utly"]').toggleClass('utly-down-arrow utly-up-arrow'); 650 dropdown.removeClass('dropshadow'); 651 } 652 if(!($(this).find('.mega-menu').hasClass('globalhomesearchbar'))){ 653 $(this).find('div.mega-menu').addClass('show'); 654 } 655 if($(this).find('.tab-down-arrow')) { 656 $(this).find('.tab-down-arrow').addClass('tab-up-arrow') 657 $(this).find('.tab-down-arrow').removeClass('tab-down-arrow') 658 } 659 var link = $(this).find('a.megamenu'); 660 setTimeout(function(){ 661 $(link).addClass('enable-link'); 662 $(link).addClass('enable-ipadpro-link'); 663 }, 300); 664 } 665 } 666 }); 667 668 $('#meganav li.mega-drop-down').mouseout(function() { 669 if((window.innerWidth>=992)) { 670 if($(this).find('.tab-up-arrow')) { 671 $(this).find('.tab-up-arrow').addClass('tab-down-arrow') 672 $(this).find('.tab-up-arrow').removeClass('tab-up-arrow') 673 } 674 } 675 }); 676 677 $('li.mega-drop-down .megamenu').click(function() { 678 var ele = $(this).parent(); 679 if((window.innerWidth < 992)) { 680 if($(ele).hasClass('dropshadow')) { 681 $('.dropshadow').removeClass('dropshadow'); 682 } else { 683 //added to remove the fadeOut class when moving from desktop to mobile 684 $('li.mega-drop-down .dropshadow').removeClass('dropshadow'); 685 $(ele).addClass('dropshadow'); 686 687 $(ele).addClass('dropshadow'); 688 } 689 $(ele).find('.megamenu').removeClass('fadeout').show(); 690 } 691 }); 692 693 $(document).mouseup(function(e) { 694 var dropdown = $('li.mega-drop-down.dropshadow'); 695 var openMenu = $(dropdown).find('.mega-menu'); 696 openMenu = openMenu[0]; 697 if(openMenu) 698 if(!openMenu.contains(e.target) && (!dropdown.is(e.target) && dropdown.has(e.target).length === 0) || (dropdown.length === 0)) { 699 dropdown.find('[class*="utly"]').toggleClass('utly-down-arrow utly-up-arrow'); 700 dropdown.removeClass('dropshadow'); 701 dropdown.find('[class*="tab"]').toggleClass('tab-down-arrow tab-up-arrow'); 702 } 703 }); 704 705 $('header a').on('click', function(e) { 706 $(this).find('[class*="arrow"]').toggleClass('tab-up-arrow tab-down-arrow'); 707 $(this).find('[class*="utly"]').toggleClass('utly-up-arrow utly-down-arrow'); 708 }); 709 $('.collapse').collapse(); 710 711 //Sticky nav - just tried some pure javascript 712 const body = document.body; 713 const header = document.querySelector(".header-container"); 714 const backtotop = document.querySelector(".backtotop"); 715 const scrollUp = "scroll-up"; 716 const scrollDown = "scroll-down"; 717 const mobScrollUp = "mob-scrolling-up"; 718 const mobScrollDown = "mob-scrolling-down"; 719 var lastScroll = 0; 720 721 window.addEventListener("scroll", function() { 722 if(window.innerWidth > 991) { 723 const currentScroll = window.pageYOffset; 724 if(currentScroll == 0) { 725 body.classList.remove(scrollUp); 726 $(header).removeClass('sticky-nav'); 727 backtotop.style.display = "none"; 728 return ; 729 } 730 if(currentScroll > lastScroll && !body.classList.contains(scrollDown)) { 731 //down 732 body.classList.remove(scrollUp); 733 body.classList.add(scrollDown); 734 } else if(currentScroll < lastScroll && body.classList.contains(scrollDown)) { 735 //up 736 body.classList.remove(scrollDown); 737 body.classList.add(scrollUp); 738 $(header).addClass('sticky-nav') 739 backtotop.style.display = "block"; 740 } 741 lastScroll = currentScroll; 742 } 743 if(window.innerWidth < 991){ 744 const currentScroll = window.pageYOffset; 745 if(currentScroll == 0) { 746 body.classList.remove(mobScrollUp); 747 return ; 748 } 749 if(currentScroll > lastScroll && !body.classList.contains(mobScrollDown)) { 750 //down 751 body.classList.remove(mobScrollUp); 752 body.classList.add(mobScrollDown); 753 } else if(currentScroll < lastScroll && body.classList.contains(mobScrollDown)) { 754 //up 755 body.classList.remove(mobScrollDown); 756 body.classList.add(mobScrollUp); 757 } 758 lastScroll = currentScroll; 759 } 760 }); 761 762 //fadeout animation for main navigation 763 const megaNav = document.querySelector('#meganav'); 764 const megaNavItems = document.querySelectorAll('#meganav li.mega-drop-down'); 765 var activeItem; 766 //on and off timer to hold the timeout functions for opening and closing menu. 767 var onTimer; 768 var offTimer; 769 var searchoffTimer; 770 //open and close main navigation menu on hover and leave. The corresponding timers are closed in each case to facilitiate the delayed opening and closing of menu. 771 $('#meganav li.mega-drop-down').mouseover(function() { 772 var openMenu = $('#meganav li.mega-drop-down.dropshadow'); 773 if(window.innerWidth >= 992) { 774 var menu = $(this); 775 var currenrSearchFlag=menu.find('.mega-menu').hasClass('globalhomesearchbar'); 776 if(!currenrSearchFlag){ 777 clearTimeout(offTimer); 778 onTimer = setTimeout(function() { 779 menu.addClass('dropshadow'); 780 menu.find('.mega-menu').removeClass('fadeOut'); 781 menu.find('.mega-menu').addClass('fadeIn'); 782 menu.find('.mega-menu').addClass('show-nav-menu'); 783 784 }, 300); 785 } 786 } 787 }).mouseleave(function() { 788 var currentMenu = $(this); 789 var currenrSearchFlag=currentMenu.find('.mega-menu').hasClass('globalhomesearchbar'); 790 if(window.innerWidth >= 992 && !currenrSearchFlag) { 791 clearTimeout(onTimer); 792 if(($('#meganav li.mega-drop-down.dropshadow').length > 0)){ 793 var openMenu = $('#meganav li.mega-drop-down.dropshadow'); 794 closeMenu(openMenu); 795 } 796 $(this).find('a.megamenu.enable-ipadpro-link').removeClass('enable-ipadpro-link'); 797 $(this).find('a.megamenu.enable-link').removeClass('enable-link'); 798 $(this).find('.mega-menu').removeClass('show'); 799 var openMenu = $(this); 800 offTimer = setTimeout(function() { 801 openMenu.find('.mega-menu').addClass('fadeOut'); 802 openMenu.removeClass('dropshadow'); 803 setTimeout(function() { 804 openMenu.find('.mega-menu').removeClass('show-nav-menu'); 805 openMenu.removeClass('fadeIn'); 806 }, 500); 807 }, 500); 808 } 809 }); 810}); 811 812function closeMenu(menu) { 813 if(window.innerWidth >= 992) { 814 menu.find('a.megamenu.enable-ipadpro-link').removeClass('enable-ipadpro-link'); 815 menu.find('a.megamenu.enable-link').removeClass('enable-link'); 816 menu.find('.mega-menu').removeClass('show'); 817 setTimeout(function() { 818 menu.find('.mega-menu').addClass('fadeOut'); 819 menu.removeClass('dropshadow'); 820 setTimeout(function() { 821 menu.find('.mega-menu').removeClass('show-nav-menu'); 822 menu.removeClass('fadeIn'); 823 }, 500); 824 }, 500); 825 } 826} 827 828function backToTop() { 829 $('html, body').animate({ 830 scrollTop: 0 831 }, 400); 832} 833 834function showMainNavSearchonHover(){ 835 var onTimer; 836 var offTimer; 837 var searchoffTimer; 838 $('#meganav li.mega-drop-down').mouseover(function() { 839 if((window.innerWidth>=992)) { 840 var currenrSearchFlag=$(this).find('.mega-menu').hasClass('globalhomesearchbar'); 841 if(!currenrSearchFlag){ 842 closeDropdown(); 843 var dropdown = $('#utinav li.mega-drop-down.dropshadow'); 844 if (dropdown.length > 0) { 845 dropdown.find('[class*="utly"]').toggleClass('utly-down-arrow utly-up-arrow'); 846 dropdown.removeClass('dropshadow'); 847 } 848 $(this).find('div.mega-menu').addClass('show'); 849 if($(this).find('.tab-down-arrow')) { 850 $(this).find('.tab-down-arrow').addClass('tab-up-arrow') 851 $(this).find('.tab-down-arrow').removeClass('tab-down-arrow') 852 } 853 var link = $(this).find('a.megamenu'); 854 setTimeout(function(){ 855 $(link).addClass('enable-link'); 856 $(link).addClass('enable-ipadpro-link'); 857 }, 300); 858 } 859 } 860 }); 861 862 $('#meganav li.mega-drop-down').mouseover(function() { 863 var openMenu = $('#meganav li.mega-drop-down.dropshadow'); 864 if(window.innerWidth >= 992) { 865 var menu = $(this); 866 var currenrSearchFlag=menu.find('.mega-menu').hasClass('globalhomesearchbar'); 867 if(!currenrSearchFlag){ 868 clearTimeout(offTimer); 869 onTimer = setTimeout(function() { 870 menu.addClass('dropshadow'); 871 menu.find('.mega-menu').removeClass('fadeOut'); 872 menu.find('.mega-menu').addClass('fadeIn'); 873 menu.find('.mega-menu').addClass('show-nav-menu'); 874 }, 300); 875 } 876 } 877 }).mouseleave(function() { 878 var currentMenu = $(this); 879 var currenrSearchFlag=currentMenu.find('.mega-menu').hasClass('globalhomesearchbar'); 880 if(window.innerWidth >= 992 && !currenrSearchFlag) { 881 clearTimeout(onTimer); 882 if(($('#meganav li.mega-drop-down.dropshadow').length > 0)){ 883 var openMenu = $('#meganav li.mega-drop-down.dropshadow'); 884 closeMenu(openMenu); 885 } 886 $(this).find('a.megamenu.enable-ipadpro-link').removeClass('enable-ipadpro-link'); 887 $(this).find('a.megamenu.enable-link').removeClass('enable-link'); 888 $(this).find('.mega-menu').removeClass('show'); 889 var openMenu = $(this); 890 offTimer = setTimeout(function() { 891 openMenu.find('.mega-menu').addClass('fadeOut'); 892 openMenu.removeClass('dropshadow'); 893 setTimeout(function() { 894 openMenu.find('.mega-menu').removeClass('show-nav-menu'); 895 openMenu.removeClass('fadeIn'); 896 }, 500); 897 }, 500); 898 } 899 }); 900} 901 902 903 904 905 906$(".goicon").css('display','block');
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.