1/** 2 * only the common functionalities that are applicable globally will be in global.js 3 */ 4 5//loading all angular app programmatically to avoid conflicts with other angular apps on same page 6angular.element(document).ready(function () { 7 // iterate all tag which have the "wdAngularApp" marker class 8 var ngAppElements = $(".wdAngularApp"); 9 ngAppElements.each(function(){ 10 11 try { 12 var ngAppElement = $(this); 13 var isInitialized = ngAppElement.injector(); 14 if (!isInitialized) { 15 var angAppName = ngAppElement.attr('data-angular-app'); 16 // bootstrap the angular app with element 17 angular.bootstrap(ngAppElement, [angAppName]); 18 } 19 } catch(err){ 20 console.log("Error while bootstrapping angular: " + err.message); 21 } 22 23 }); 24 25}); 26 27//common excelToJson function 28function getJsonFrmExcelSheet(excelPath, sheetName) { 29 var servletUrl = ""; 30 //form servletUrl if sheetName is authored or not 31 if(sheetName){ 32 servletUrl = excelPath+".exceltojson."+sheetName+".json"; 33 } else{ 34 servletUrl = excelPath+".exceltojson.json"; 35 } 36 // call ExcelToJsonServlet and return the json of the excel data 37 return $.get(servletUrl); 38} 39 40//resolve IE issue for startsWith 41if (!String.prototype.startsWith) { 42 Object.defineProperty(String.prototype, 'startsWith', { 43 value: function(search, pos) { 44 pos = !pos || pos < 0 ? 0 : +pos; 45 return this.substring(pos, pos + search.length) === search; 46 } 47 }); 48} 49 50// resolve IE issue for includes 51if (!String.prototype.includes) { 52 String.prototype.includes = function(search, start) { 53 'use strict'; 54 if (typeof start !== 'number') { 55 start = 0; 56 } 57 58 if (start + search.length > this.length) { 59 return false; 60 } else { 61 return this.indexOf(search, start) !== -1; 62 } 63 }; 64} 65 66// resolve IE issue for MAX_SAFE_INTEGER 67if (!Number.MAX_SAFE_INTEGER) { 68 Number.MAX_SAFE_INTEGER = 9007199254740991; // Math.pow(2, 53) - 1; 69} 70 71//resolve IE issue for MIN_SAFE_INTEGER 72if (!Number.MIN_SAFE_INTEGER) { 73 Number.MIN_SAFE_INTEGER = -9007199254740991; // Math.pow(2, 53) - 1; 74} 75 76// Used for Zoom Effect in Image Component 77$(document).ready(function(){ 78 $('.zoomimage').each(function(){ 79 $(this).click(function(){ 80 if($('body').find('.ZoomContainer').length){ 81 $('.ZoomContainer').remove(); 82 }else{ 83 $(this).ezPlus({ 84 zoomActivation: 'click', 85 zoomType: 'inner', 86 cursor: 'crosshair', 87 responsive : true, 88 respond: [ 89 { 90 range: '0-992', 91 enabled: false, 92 showLens: false, 93 zoomType: false, 94 } 95 ] 96 }); 97 } 98 }) 99 }) 100}) 101 102 103//Angular app for common functionalities 104var CommonUtilApp = angular.module('CommonUtilApp', []); 105CommonUtilApp.service('CommonUtilService', [function () { 106 107 // Function to rewrite page url's to avoid redirects in dispatcher 108 this.rewritePageURL = function (url) { 109 var rootPathToReplaceInURL = $("#commonUtilLoad").attr("data-rootPathToReplaceInURL"); 110 // Check if the url is content page(internal) url 111 if (url && url.indexOf(rootPathToReplaceInURL) > -1) { 112 if (this.isPublishInstance()) { 113 return url.replace(rootPathToReplaceInURL, '').replace('.html', ''); 114 } else { 115 return url.indexOf('.html') < 0 ? url + ".html" : url; 116 } 117 } else { 118 return url; 119 } 120 }; 121 122 // Function to rewrite page url's to avoid redirects in dispatcher and return url appended with .html 123 this.rewritePageURLWithHTML = function (url) { 124 url = this.rewritePageURL(url); 125 return url.indexOf('.html') < 0 ? url + ".html" : url; 126 }; 127 128 // Function to check whether WCMMODE is disabled 129 this.isWcmModeDisabled = function () { 130 var isWcmModeDisabled = $("#commonUtilLoad").attr("data-isWcmModeDisabled"); 131 if (isWcmModeDisabled == 'true') { 132 return true; 133 } 134 return false;
135 }; 136 137 // Function to check whether Instance is Publish 138 this.isPublishInstance = function () { 139 var isPublishInstance = $("#commonUtilLoad").attr("data-isPublishInstance"); 140 if (isPublishInstance == 'true') { 141 return true; 142 } 143 return false; 144 }; 145 146 // merge value of array as single string with delimiter if provided 147 this.mergeStringArray = function (array, delimiter) { 148 if (array && Array.isArray(array)) { 149 return array.join(delimiter ? delimiter : ""); 150 } 151 return array; 152 } 153 154 // is null or empty 155 this.isNotBlank = function (val) { 156 return (val && val.length > 0) ? true : false; 157 }; 158 159 // get current page path 160 this.getCurrentPagePath = function () { 161 return $("#commonUtilLoad").attr("data-currentPagePath"); 162 }; 163 164 // get site name 165 this.getSiteName = function () { 166 return $("#commonUtilLoad").attr("data-sitename"); 167 }; 168 169 // get Locale Root path 170 this.getLocaleRootPath = function () { 171 return $("#commonUtilLoad").attr("data-rootPath"); 172 }; 173 174 // get country 175 this.getCountry = function () { 176 return $("#commonUtilLoad").attr("data-country"); 177 }; 178 179 // get language 180 this.getLanguage = function () { 181 return $("#commonUtilLoad").attr("data-language"); 182 }; 183 184 185 // get locale 186 this.getLocale = function() { 187 if (this.isNotBlank(this.getDataLocale())) { 188 return this.getDataLocale(); 189 } else { 190 return this.getLanguage() + "-" + this.getCountry(); 191 } 192 }; 193 194 //get data-locale 195 this.getDataLocale = function() { 196 return $("#commonUtilLoad").attr("data-locale"); 197 }; 198 199 //get converted date 200 this.getConvertedDate = function(date) { 201 var offsetDiff = $("#userLoad").attr("data-site-timeOffsetDiff"); 202 203 if(offsetDiff && parseFloat(offsetDiff)) { 204 return new Date(date.getTime() + (date.getTimezoneOffset() * 60000) + (3600000 * offsetDiff)); 205 } else { 206 return new Date(date.getTime() + (date.getTimezoneOffset() * 60000) + (3600000*0)); 207 } 208 }; 209 210 //get offset diff 211 this.getOffsetDiff = function() { 212 return $("#userLoad").attr("data-site-timeOffsetDiff"); 213 } 214 215 //get converted date 216 this.getTimeZone = function() { 217 return $("#userLoad").attr("data-site-timezone"); 218 }; 219 220 // Get the modified date based on the input format 221 // Example 1: currentMonth:MMM will be replaced with Jan 222 // nextMonth:MMM will be replaced with Feb 223 // prevMonth:MMM will be replaced with Dec 224 // Example 2: currentMonth:YYYY-MM-dd will be replaced with 2019-01-01 225 // nextMonth:YYYY-MM-dd will be replaced with 2019-02-01 226 // prevMonth:YYYY-MM-dd will be replaced with 2018-12-01 227 this.replaceCalendarConstant = function (dateConstant) { 228 // Check if the input date is empty or not 229 if (this.isNotBlank(dateConstant.trim())) { 230 // Check if the input date is empty or not 231 var constant = dateConstant.split(":"); 232 if(constant.length > 1) { 233 var currentDate = new Date(); 234 var modifiedDate = new Date(); 235 switch(constant[0]) { 236 case "prevDate": 237 modifiedDate.setDate(currentDate.getDate() - 1); 238 break; 239 case "nextDate": 240 modifiedDate.setDate(currentDate.getDate() + 1); 241 break; 242 case "prevMonth": 243 modifiedDate.setMonth(currentDate.getMonth() - 1); 244 break; 245 case "nextMonth": 246 modifiedDate.setMonth(currentDate.getMonth() + 1); 247 break; 248 case "prevYear": 249 modifiedDate.setFullYear(currentDate.getFullYear() - 1); 250 break; 251 case "nextYear": 252 modifiedDate.setFullYear(currentDate.getFullYear() + 1); 253 break; 254 } 255 var dd = modifiedDate.getDate(); 256 // numerical value for Jan is 0, so we add 1 257 var mm = modifiedDate.getMonth() + 1; 258 var yyyy = modifiedDate.getFullYear(); 259 var date = ""; 260 if(constant[1].indexOf("MMM") > -1) { 261 date = constant[1].replace("MMM" , modifiedDate.toString().slice(4,7)); 262 } else { 263 date = constant[1]; 264 date = date.replace(/dd/ig, dd); 265 date = date.replace(/mm/ig , mm); 266 date = date.replace(/yyyy/ig , yyyy); 267 date = date.replace(/yy/ig , yyyy.toString().slice(2,4)); 268 } 269 return date; 270 } else { 271 return dateConstant; 272 } 273 } 274 }; 275 276 /** 277 * This function checks if the path of the document 278 * falls under the restricted or protected folder.
279 * Based on the value we enable a lock icon on the document. 280 */ 281 this.isPathProtected = function (documentURL) { 282 var docPathProtected = false; 283 var protectedPath = $("#commonUtilLoad").attr("data-isPathProtected"); 284 var protectedPathArray = protectedPath.split(','); 285 protectedPathArray.forEach(function (item) { 286 if (item != null && item !== '' && documentURL != '' && documentURL.indexOf(item) > -1) { 287 docPathProtected = true; 288 } 289 }); 290 return docPathProtected; 291 }; 292 293 /** 294 * Get 13 digit Random number 295 */ 296 this.getRandomNumber = function () { 297 return new Date().getTime() * Math.floor(1 + Math.random() * 10) 298 } 299 300 /** 301 * Encode String To Base64 302 */ 303 this.encodeStringToBase64 = function (data) { 304 return btoa(unescape(encodeURIComponent(data))); 305 } 306 307 // Function to check whether to exclude Product Reference from Session 308 this.excludeProductReferenceFromSession = function () { 309 var excludeProductReferenceFromSession = $("#commonUtilLoad").attr("data-excludeProductReferenceFromSession"); 310 if (excludeProductReferenceFromSession == 'true') { 311 return true; 312 } 313 return false; 314 }; 315 316 // get timezone 317 this.getTimeZoneInfo = function () { 318 return $("#commonUtilLoad").attr("data-timeZone"); 319 }; 320 321 this.isOfferActive = function(startDate, endDate) {// check if offer is active 322 return this.isBadgeStatusActive(startDate, endDate); 323 }; 324 325 // check if badge status is active 326 this.isBadgeStatusActive = function(startDate, endDate){ 327 if (startDate) { 328 startDate = startDate.slice(0, -6);// remove time zone offset 329 } 330 if (endDate) { 331 endDate = endDate.slice(0, -6);// remove time zone offset 332 } 333 var startDateObj = new Date(startDate); 334 var endDateObj = new Date(endDate); 335 var badgeActive = false; 336 var timeZone = this.getTimeZoneInfo(); 337 var options = { 338 timeZone: "America/Los_Angeles", 339 year: 'numeric', 340 month: 'numeric', 341 day: 'numeric', 342 hour: 'numeric', 343 minute: 'numeric' 344 }, 345 formatter = new Intl.DateTimeFormat('en-US', options); 346 347 var currentDate = new Date(formatter.format(new Date())); 348 if(!startDate && !endDate){ 349 badgeActive = true; 350 }else if (startDate && endDate && currentDate >= startDateObj && currentDate <= endDateObj) { 351 badgeActive = true; 352 }else if (startDate && !endDate && currentDate >= startDateObj) { 353 badgeActive = true; 354 }else if (!startDate && endDate && currentDate <= endDateObj) { 355 badgeActive = true; 356 } 357 return badgeActive; 358 } 359 360 // get getOracleServiceCloudHost 361 this.getOracleServiceCloudHost = function () { 362 return $("#commonUtilLoad").attr("data-oracleServiceCloudHost"); 363 }; 364 365 // get getStudioAssetDetailsPagePath 366 this.getStudioAssetDetailsPagePath = function () { 367 return this.getLocaleRootPath() + "/asset-details"; 368 }; 369 370}]); 371 372/********************************/ 373/* Search Service App */ 374/********************************/ 375var searchCommonApp = angular.module('SearchCommonApp', ['ngSanitize']); 376 377searchCommonApp.service('AutoSuggestService', ['$q', '$http', '$timeout', function ($q, $http, $timeout) { 378 379 //get auto suggest results 380 this.getAutoSuggestResults = function (q, autoSuggestUrl) { 381 var suggestTextTimeout, suggestText; 382 suggestText = q; 383 var deferred = $q.defer(); 384 if (suggestText && suggestText.length >= 3) { 385 if (suggestTextTimeout) $timeout.cancel(suggestTextTimeout); 386 //forming the autosuggest url 387 var url = autoSuggestUrl + ((autoSuggestUrl && autoSuggestUrl.indexOf('?') >= 0) ? '&' : '?') + 'q=' + encodeURIComponent(suggestText) + '&omitHeader=true&wt=json&distrib=false'; 388 suggestTextTimeout = $timeout(function() { 389 $http.get(url).then(function(resp) { 390 var data = resp.data; 391 if(suggestText.length >= 3 && resp.data.response.docs && resp.data.response.numFound > 0) { 392 //getting the suggestions from response 393 deferred.resolve(data); 394 } 395 }, function(response) { 396 search_commonLoggerObj('error: ', response.data); 397 deferred.reject(); 398 }); 399 }, 500); 400 } else { 401 deferred.reject(); 402 } 403 return deferred.promise; 404 }; 405 406}]); 407 408searchCommonApp.service('SearchFacetsService', ['$q', '$http', '$timeout', function ($q, $http, $timeout) { 409 410 //get selected sub-document type facets
411 this.getSelectedSubDocumentTypeFacets = function (jsonData) { 412 var subDocTypeFacetURL = ''; 413 angular.forEach(jsonData, function(facetVal){ 414 if (facetVal.selected){ //checking if sub doc type facet is selected 415 subDocTypeFacetURL = subDocTypeFacetURL != '' ? subDocTypeFacetURL + '%20OR%20' : ''; 416 subDocTypeFacetURL += '%22' + facetVal.facetName + '%22'; 417 } 418 }) 419 return subDocTypeFacetURL; 420 }; 421 422 // get sub document type facets json 423 this.getSubDocTypeFacetsJson = function (q, docTypeFacetURL, subDocTypeFacetURL, facetQueryEndPoint, otherLabel) { 424 425 var filterQueryDocType = docTypeFacetURL != '' ? '&fq=' + docTypeFacetURL : docTypeFacetURL; 426 var deferred = $q.defer(); 427 //forming the facet url 428 var searchFacetsURL = facetQueryEndPoint + ((facetQueryEndPoint && facetQueryEndPoint.indexOf('?') >= 0) ? '&' : '?') + 'q=' + encodeURIComponent(q != undefined && q != ''? q : '*.*') + filterQueryDocType + '&facet.field=filterSubDocumentType&wt=json'; 429 $http.get(searchFacetsURL).then(function(response) { 430 var data = response.data; 431 jsonData = []; 432 var othersCount = ''; 433 var subDocumentTypeFacets= data.facet_counts.facet_fields.filterSubDocumentType; 434 //adding the facets response to array 435 for(var i=0; i<subDocumentTypeFacets.length; i++){ 436 //adding all facets apart from Other to the array 437 if(subDocumentTypeFacets[i] != '' && subDocumentTypeFacets[i] != 'Other'){ 438 jsonData.push({ 439 'facetName': subDocumentTypeFacets[i], 440 'facetCount': subDocumentTypeFacets[i + 1], 441 'selected': subDocTypeFacetURL != '' ? (subDocTypeFacetURL.indexOf(subDocumentTypeFacets[i]) >= 0 ? true : false) : false 442 }); 443 }else if(subDocumentTypeFacets[i] == 'Other'){ 444 othersCount = subDocumentTypeFacets[i + 1]; 445 } 446 i += 1; 447 } 448 //adding 'Other' facet at the end 449 if(othersCount != ''){ 450 jsonData.push({ 451 'facetName': otherLabel, 452 'facetCount': othersCount, 453 'selected': subDocTypeFacetURL != '' ? (subDocTypeFacetURL.indexOf(otherLabel) >= 0 ? true : false) : false 454 }); 455 } 456 deferred.resolve(jsonData); 457 }); 458 459 return deferred.promise; 460 }; 461 462}]); 463 464searchCommonApp.service('SearchResultsService', ['$q', '$http', '$timeout', '$location', '$window', function ($q, $http, $timeout, $location, $window) { 465 sr_this = this; 466 467 this.trackInternalSearch = function (q, numFound, filterBy){ 468 var searchObj = {} 469 searchObj["q"] = q; 470 searchObj["searchTermsCount"] = numFound; 471 searchObj["filterBy"] = []; 472 searchObj["filterBy"] = filterBy != '' ? decodeURIComponent((filterBy).replace(new RegExp('%22','g'), '').split("OR")).split(",") : 'All'; 473 try{ 474 var event = window.aa.createEvent("SEARCH", searchObj); 475 window.dispatchEvent(event); 476 } catch(e){ 477 search_commonLoggerObj("Error while triggering analytics Search event."); 478 } 479 } 480 481 //get selected sub-document type facets 482 this.getSearchResults = function (q, searchBaseUrl, searchParams, docTypeFacetURL, subDocTypeFacetURL, aaTrack) { 483 484 var deferred = $q.defer(); 485 486 var url = sr_this.getSearchUrl(q, searchBaseUrl, searchParams); 487 488 //forming search query url when doc/sub-doc type filters are selected 489 if(docTypeFacetURL != '' && subDocTypeFacetURL != ''){ 490 url = url + '&fq=' + subDocTypeFacetURL + '%20AND%20' + docTypeFacetURL; 491 }else if(docTypeFacetURL != '' && subDocTypeFacetURL == ''){ 492 url = url + '&fq=' + docTypeFacetURL; 493 }else if(docTypeFacetURL == '' && subDocTypeFacetURL != ''){ 494 url = url + '&fq=' + subDocTypeFacetURL; 495 } 496 497 //getting the search results 498 $http.get(url).then(function(resp) { 499 var data = resp.data; 500 var numFound = data.response.numFound; 501 //[[start - anaytics tracking code 502 if(aaTrack){ 503 sr_this.trackInternalSearch(q, numFound, subDocTypeFacetURL); 504 } 505 aaTrack = false;
506 //[[end - anaytics tracking code 507 508 deferred.resolve(data); 509 }, function(response) { 510 search_commonLoggerObj('error: ', response.data); 511 sr_this.trackInternalSearch(q, 0, subDocTypeFacetURL); 512 aaTrack = false; 513 deferred.reject(); 514 }); 515 return deferred.promise; 516 }; 517 518 // get search url 519 this.getSearchUrl = function (q, searchBaseUrl, searchParams) { 520 var url = searchBaseUrl + ((searchBaseUrl && searchBaseUrl.indexOf('?') >= 0) ? '&' : '?') + 'q=' + encodeURIComponent(q != undefined && q != ''? q : '*:*'); 521 searchParams['wt'] = 'json'; //set return type as json 522 for (key in searchParams) { 523 if (Object.prototype.toString.call(searchParams[key]) === '[object Array]') { 524 angular.forEach(searchParams[key], function(p) { 525 url += "&" + key + "=" + p; 526 }); 527 } else { 528 url += "&" + key + "=" + searchParams[key]; 529 } 530 } 531 return url; 532 }; 533 534 //get product search results 535 this.getProductSearchResults = function (produrl) { 536 // store search get product data 537 var deferred = $q.defer(); 538 $http.get(produrl).then(function(response) { 539 var data = response.data; 540 deferred.resolve(data); 541 }); 542 return deferred.promise; 543 }; 544 545}]); 546 547//search logger for object function 548function search_commonLoggerObj(msg, obj) { 549 // apply debug if 'debugSearch=true' in url param 550 if (window.location.search.indexOf('debugSearch=true') > -1) { 551 console.log(msg,(obj!=null?obj:'')); 552 } 553} 554 555/** 556 * Campaign controller 557 */ 558var campaignApp = angular.module('CampaignApp', ['CommonUtilApp']); 559 560campaignApp.service('CampaignService', ['$q', '$sce', '$cookies', 'CommonUtilService', 'CommerceService', 'COMMERCE_CONSTANTS', function ($q, $sce, $cookies, CommonUtilService, CommerceService, COMMERCE_CONSTANTS) { 561 campaign_commonLogger("in CampaignService..."); 562 campaign_this = this; 563 var isCatalogPurchasable = CommerceService.getPurchasableCatalog(); 564 565 // get user info 566 this.getUserInfo = function(){ 567 campaign_commonLogger("in getUserInfo..."); 568 var deferred = $q.defer(); 569 570 campaign_commonLogger("in getUserInfo... isCatalogPurchasable: " + isCatalogPurchasable); 571 if(isCatalogPurchasable){ 572 573 var sessionUserDetails = CommerceService.getSessionVariable(COMMERCE_CONSTANTS.USER_DETAILS); 574 575 // check if group info is available in session storage 576 if (null != sessionUserDetails) { 577 campaign_commonLogger("in getUserInfo: user details found in session"); 578 579 if(typeof sessionUserDetails.uid != 'undefined'){ 580 sessionUserDetails = CommerceService.getSessionVariable(COMMERCE_CONSTANTS.USER_DETAILS); 581 deferred.resolve(sessionUserDetails.userGroups); 582 } else { 583 deferred.resolve(null); 584 } 585 586 }else { 587 campaign_commonLogger("in getUserInfo: user details not found in session"); 588 589 CommerceService.getUser().then(function () { 590 sessionUserDetails = CommerceService.getSessionVariable(COMMERCE_CONSTANTS.USER_DETAILS); 591 if(sessionUserDetails != null && typeof sessionUserDetails.uid != 'undefined'){ 592 deferred.resolve(sessionUserDetails.userGroups); 593 } else { 594 deferred.resolve(null); 595 } 596 },function(xhr){ 597 campaign_this.createErrorObject(deferred, "in getUserInfo: user info error ...", xhr); 598 }); 599 } 600 }else { 601 602 // when catalog is not purchasable then we don't make get user call 603 deferred.resolve(null); 604 } 605 606 return deferred.promise; 607 }; 608 609 // create brand query 610 this.createBrandQuery = function(brandFilter){ 611 612 var createBrandQuery = ''; 613 if(brandFilter != ''){ 614 615 createBrandQuery = '102_property=attConditionBrand&102_property.1_value='+ encodeURIComponent("%") + 'all' + encodeURIComponent("%") + '&'; 616 brandFilterArray = brandFilter.split(','); 617 618 if(brandFilterArray.length > 0){ 619 620 // create brand query 621 for(var i=0; i<brandFilterArray.length; i++){ 622 createBrandQuery = createBrandQuery + "102_property." + (i+2) + "_value=" + encodeURIComponent("%") + brandFilterArray[i] + encodeURIComponent("%") + "&"; 623 } 624 createBrandQuery = createBrandQuery + '102_property.operation=like'; 625 } 626 }else if(brandFilter == ''){ 627 628 createBrandQuery = '102_property=attConditionBrand&102_property.1_value='+ encodeURIComponent("%") + 'all' + encodeURIComponent("%") + '&102_property.operation=like'; 629 } 630 631 return createBrandQuery; 632 }; 633 634 // create channel query
635 this.createChannelQuery = function(channel) { 636 637 var createChannelQuery = '104_property=attCustChannel&104_property.1_value='+ encodeURIComponent("%") + 'all' + encodeURIComponent("%") + '&104_property.2_value='+ encodeURIComponent("%") + channel + encodeURIComponent("%") + '&104_property.operation=like'; 638 639 return createChannelQuery; 640 }; 641 642 // get campaign details 643 this.getCampaignDetails = function (query, brand) { 644 campaign_commonLogger("in getCampaignDetails..."); 645 campaign_commonLogger("query: " + query); 646 647 var userGroup = null; 648 var deferred = $q.defer(); 649 650 // create brand query 651 var brandQuery = campaign_this.createBrandQuery(brand); 652 if(query.indexOf("{attConditionBrand}") > -1){ 653 query = query.replace("{attConditionBrand}", brandQuery); 654 } 655 656 campaign_this.getUserInfo().then(function (response) { 657 658 userGroup = response; 659 campaign_commonLogger("in getCampaignDetails functions - userGroup: " + userGroup); 660 var createGroupQuery = '101_property=attConditionGroup&101_property.1_value='+ encodeURIComponent("%") + 'all' + encodeURIComponent("%") + '&'; 661 662 663 // when catalog is not purchasable then we don't send user group in query 664 if(!isCatalogPurchasable){ 665 query = query.replace("{attConditionGroup}&", ''); 666 667 // if user group is not present i.e. non-logged-in user, remove the Group property from query 668 }else if(null == userGroup & isCatalogPurchasable){ 669 670 // create group query for non-logged-in user 671 createGroupQuery = createGroupQuery + '101_property.2_value=' + encodeURIComponent("%") + 'anonymous' + encodeURIComponent("%") + '&101_property.operation=like'; 672 // update group property in query with user group 673 query = query.replace("{attConditionGroup}", createGroupQuery); 674 }else if(userGroup.length > 0){ 675 676 // create group query for logged-in user 677 for(var i=0; i<userGroup.length; i++){ 678 createGroupQuery = createGroupQuery + "101_property." + (i+2) + "_value=" + encodeURIComponent("%") + userGroup[i].id + encodeURIComponent("%") + "&"; 679 } 680 createGroupQuery = createGroupQuery + '101_property.operation=like'; 681 // update group property in query with user group 682 if(query.indexOf("{attConditionGroup}") > -1){ 683 query = query.replace("{attConditionGroup}", createGroupQuery); 684 } 685 686 } 687 688 // create applicable pages query 689 var createApplicablePagesQuery = '&103_property=urlApplicablePages&103_property.1_value='+ encodeURIComponent("%") + 'all' + encodeURIComponent("%") + '&'; 690 // get current page path 691 var currentPagePath = CommonUtilService.getCurrentPagePath(); 692 createApplicablePagesQuery = createApplicablePagesQuery + '103_property.2_value='+ encodeURIComponent("%") + currentPagePath + encodeURIComponent("%") + '&103_property.operation=like'; 693 query = query + createApplicablePagesQuery; 694 695 // create channel query 696 var channelQuery = campaign_this.createChannelQuery(CommerceService.getCustomerChannel()); 697 if(query.indexOf("{attCustChannel}") > -1){ 698 query = query.replace("{attCustChannel}", channelQuery); 699 } 700 701 campaign_commonLogger("updated query: " + query); 702 703 // make service call to get the campaign info 704 $.ajax({ 705 url: "/bin/wd/campaignQuery.json?" + query, 706 type: 'GET' 707 }).then(function (response) { 708 deferred.resolve(response); 709 }, 710 function (xhr) { 711 // handle error 712 campaign_this.createErrorObject(deferred, "failed to get campaign info from service", xhr); 713 }); 714 715 }); 716 return deferred.promise; 717 }; 718 719 // create generic error object 720 this.createErrorObject = function (deferred, msg, xhr) { 721 var error = {}; 722 error.status = (xhr) ? xhr.status : -1; 723 error.statusText = (xhr) ? xhr.statusText : "this is not a service response error but custom processing error"; 724 error.responseText = msg + ((xhr) ? ", serviceResponseText: " + xhr.responseText : ""); 725 campaign_errorLogger(JSON.stringify(error)); 726 727 // deferred can be null where we don't want to throw error/rejection as its just a warning e.g. from try-catch error 728 if (deferred) { 729 deferred.reject(error); 730 return deferred.promise; 731 } 732 }; 733 734}]); 735 736// common logger function 737function campaign_commonLogger(msg) { 738 // apply debug if 'debugCampaign=true' in url param 739 if (window.location.search.indexOf('debugCampaign=true') > -1) { 740 console.log("Store Campaign Service: " + msg); 741 } 742} 743 744//error logger function 745function campaign_errorLogger(msg) { 746 console.log(msg); 747} 748 749//common logger for object function 750function campaign_commonLoggerObj(msg, obj) { 751 // apply debug if 'debugCampaign=true' in url param 752 if (window.location.search.indexOf('debugCampaign=true') > -1) { 753 console.log("CSH: " + msg + "->"); 754 console.log(obj); 755 } 756} 757 758document.addEventListener('DOMContentLoaded', function () { 759 var isWcmModeDisabled = document.getElementById("commonUtilLoad").getAttribute("data-isWcmModeDisabled"); 760 var header = document.querySelector('header.header') || ''; 761 if (document.querySelector('.headerContainer') && document.querySelector('header.header')) { 762 document.querySelector('body').classList.add('has-header-container'); 763 } 764 // for header 2.5 only 765 if (document.querySelector('.wd-header-2-5') && header && document.querySelector('.subnav2-0')) { 766 setTimeout(function () { 767 var headerHeight = header.offsetHeight; 768 header.style.position = 'sticky'; 769 var stickyNav = document.querySelector('#sticky-nav') || ''; 770 if (stickyNav) { 771 stickyNav.style.position = 'relative'; 772 } 773 }, 500); 774 } else if (header) { 775 setTimeout(function () { 776 var headerHeight = header.offsetHeight; 777 var stickyNav = document.querySelector('#sticky-nav') || ''; 778 header.style.top = 0; 779 if (document.querySelector('.wd-header-2-5') && !document.querySelector('.headerContainer')) { 780 header.style.position = 'sticky'; 781 } else { 782 header.style.position = 'sticky'; 783 } 784 if (stickyNav) { 785 stickyNav.style.top = `${headerHeight}px`; 786 } 787 }, 500); 788 } 789 790 if (isWcmModeDisabled && isWcmModeDisabled == 'true') { 791 // updateStoreHeader(); 792 } 793 if (document.querySelector('.wdJavaScript') && document.querySelector('.wdJavaScript').length) { 794 document.querySelector('header.header').classList.add('wd-header-2-0'); 795 var navbarHeight = document.querySelector('header.header').offsetHeight; 796 var lastScrollTop = 0; 797 var isInSmallDevice = window.outerWidth < 992; 798 window.addEventListener('resize', function () { 799 navbarHeight = document.querySelector('header.header').offsetHeight; 800 isInSmallDevice = window.outerWidth < 992; 801 var sticky = document.querySelector('.sticky'); 802 var stickyStuck = document.querySelector('.sticky-stuck'); 803 if (document.querySelector('header.header').classList.contains('headerHidden')) { 804 if (sticky) sticky.style.top = `0px`; 805 if (stickyStuck) stickyStuck.style.top = `0px`; 806 } else { 807 if (sticky) sticky.style.top = `${navbarHeight}px`; 808 if (stickyStuck) stickyStuck.style.top = `${navbarHeight}px`; 809 } 810 }); 811 } 812 //add class on ios devices only. 813 if (!/iP(ad|hone|od)/.test(navigator.userAgent)) { 814 document.querySelector('body').classList.add('ios-device'); 815 } 816}); 817// resize event for 2.5 header 818window.addEventListener('resize', function () { 819 if (document.querySelector('.wd-header-2-5')) { 820 document.querySelectorAll('.middleMenu li[id]').forEach(function (elm) { 821 if (elm.classList.contains('active')) { 822 executeSlidingBar(elm); 823 } 824 }); 825 } 826}); 827function getAllSiblings(element, parent) { 828 const children = [...parent.children]; 829 return children.filter(child => child !== element); 830} 831// function isMobileDevice() { 832// var check = false;
833// (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); 834// return check; 835// }; 836var defaultBreadcrumbView = document.querySelector('.defaultBreadcrumbView '); 837var header = document.querySelector('header.header') || ''; 838var defaultBreadcrumbViewHeight; 839var headerHeight = header.offsetHeight; 840if (defaultBreadcrumbView && document.querySelector('.wd-header-2-5') && !(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))) { 841 defaultBreadcrumbViewHeight = getOffset(defaultBreadcrumbView); 842 var navigationListHeight; 843 if (document.querySelector('.desktop-navigation-list')) { 844 navigationListHeight = document.querySelector('.desktop-navigation-list').offsetHeight; 845 } 846 if (navigationListHeight) { 847 var totalHeight = headerHeight + navigationListHeight; 848 if (document.querySelector('.left-filter-container')) { 849 document.querySelector('.left-filter-container').style.top = `${navigationListHeight}px`; 850 // document.querySelector('.left-filter-container').style.setProperty('height', `calc(100vh - (${totalHeight}px))`); 851 } 852 } 853} 854function HideandShowHeader() { 855 var header = document.querySelector('header.header') || ''; 856 var windowTop = window.scrollY; 857 var DefaultTop = 0; 858 var brandpannel = document.querySelector('.wd-header-2-5 .header-2-5') || ''; 859 var brandpannelHeight = brandpannel.offsetHeight; 860 var stickyNav = document.querySelector('#sticky-nav') || ''; 861 var navigationItems = document.querySelectorAll('.dropDownContainer.productNavWrapper') || ''; 862 if (document.querySelector('.wd-header-2-5')) { 863 var headerHeight = header.offsetHeight; 864 if (!stickyNav && brandpannel) { 865 if (windowTop === brandpannelHeight) { 866 header.style.top = `-${brandpannelHeight}px`; 867 if (window.inner >= 992) { 868 navigationItems.forEach(function (elm) { 869 elm.style.top = `${headerHeight - brandpannelHeight}px`; 870 }); 871 } 872 } else if (windowTop < brandpannelHeight) { 873 header.style.top = `-${windowTop}px`; 874 document.querySelector('body').classList.remove('minHeader'); 875 if (window.inner >= 992) {
876 navigationItems.forEach(function (elm) { 877 elm.style.top = `${headerHeight - windowTop}px`; 878 }); 879 } 880 } else if (windowTop > brandpannelHeight) { 881 header.style.top = `-${brandpannelHeight}px`; 882 document.querySelector('body').classList.add('minHeader'); 883 if (window.inner >= 992) { 884 navigationItems.forEach(function (elm) { 885 elm.style.top = `${headerHeight - brandpannelHeight}px`; 886 }); 887 } 888 } 889 } 890 if (windowTop > DefaultTop && windowTop > headerHeight) { 891 if (stickyNav) { 892 stickyNav.style.position = 'fixed'; 893 stickyNav.style.top = `0`; 894 document.querySelector('body').classList.remove('minHeader'); 895 } 896 } else { 897 if (stickyNav) { 898 stickyNav.style.position = 'relative'; 899 document.querySelector('body').classList.remove('minHeader'); 900 } 901 } 902 } else if (header) { 903 var headerHeight = header.offsetHeight; 904 if (windowTop > DefaultTop && windowTop > headerHeight) { 905 header.style.top = `-${headerHeight}px`; 906 header.style.position = 'fixed'; 907 header.classList.add('headerHidden'); 908 if (stickyNav) { 909 stickyNav.style.top = `0`; 910 } 911 } else { 912 header.style.top = `0`; 913 header.style.position = 'fixed'; 914 header.classList.remove('headerHidden'); 915 if (stickyNav) { 916 stickyNav.style.top = `${headerHeight}px`; 917 } 918 } 919 DefaultTop = windowTop; 920 } 921} 922function getOffset(element) { 923 if (!element.getClientRects().length) { 924 return { top: 0, left: 0 }; 925 } 926 927 let rect = element.getBoundingClientRect(); 928 let win = element.ownerDocument.defaultView; 929 return ( 930 { 931 top: rect.top + win.pageYOffset, 932 left: rect.left + win.pageXOffset 933 }); 934} 935window.onscroll = function () { 936 HideandShowHeader(); 937}; 938// when header 2-5 is contributed.. 939if (document.querySelector('.wd-header-2-5') && window.innerWidth >= 991) { 940 setTimeout(function() { 941 document.querySelectorAll('.middleMenu li[id]').forEach(function (elm) { 942 elm.addEventListener('click', function (e) { 943 var thisID = elm.getAttribute('aria-controls'); 944 document.querySelector('header').querySelectorAll('.productNavWrapper').forEach(function (Pelm) { 945 Pelm.addEventListener('click', function (e) { 946 e.stopPropagation(); 947 }); 948 var id = Pelm.getAttribute('id'); 949 if (thisID === id) { 950 if (elm.classList.contains('active')) { 951 Pelm.classList.remove('megaMenuOpen'); 952 Pelm.classList.add('hidden'); 953 elm.classList.remove('border-b-4', 'border-blue', 'text-blue'); 954 //Pelm.style.display = 'none'; 955 elm.closest('.middleMenu').querySelector('.slidingDiv').style.visibility = 'hidden'; 956 } 957 if (!elm.classList.contains('active')) { 958 setTimeout(function () { 959 Pelm.classList.add('megaMenuOpen'); 960 Pelm.classList.remove('hidden'); 961 executeSlidingBar(elm); 962 //Pelm.style.display = 'block'; 963 var allSiblings = getAllSiblings(elm, elm.closest('.middleMenu')); 964 if (allSiblings.length > 0) { 965 allSiblings.map(function (eachNav) { 966 eachNav.classList.remove('active'); 967 eachNav.classList.remove('border-b-4', 'border-blue', 'text-blue') 968 }) 969 } 970 }, 200); 971 } else { 972 setTimeout(function () { 973 if (thisID != id) { 974 Pelm.classList.remove('megaMenuOpen'); 975 Pelm.classList.add('hidden'); 976 elm.classList.remove('border-b-4', 'border-blue', 'text-blue'); 977 //Pelm.style.display = 'none'; 978 elm.closest('.middleMenu').querySelector('.slidingDiv').visibility = 'hidden'; 979 } 980 }, 200); 981 } 982 // elm.classList.add('active'); 983 } else { 984 Pelm.classList.add('hidden'); 985 // Pelm.classList.remove('megaMenuOpen'); 986 // elm.classList.remove('active'); 987 if (document.querySelector(`[aria-controls="${id}"]`)) { 988 document.querySelector(`[aria-controls="${id}"]`).classList.remove('border-b-4', 'border-blue', 'text-blue'); 989 } 990 } 991 }); 992 elm.classList.toggle('active'); 993 }); 994 }); 995 }, 1500); 996 997 //Brand Dropdown menu 998 if (document.querySelector('.header-2-5') && document.querySelector('.header-container')) { 999 var headerBrandDropDown = document.querySelector(' .dd-button') || ''; 1000 if (headerBrandDropDown) { 1001 headerBrandDropDown.addEventListener('click', function () { 1002 headerBrandDropDown.classList.toggle('dropDownOpen'); 1003 }) 1004 } 1005 } 1006 1007 // end of header 2-5 1008} else { 1009 if (document.querySelector('.middleMenu') && window.outerWidth >= 991) {
1010 var slidingDivCheck = false; 1011 document.querySelectorAll('.middleMenu li[id]').forEach(function (elm) { 1012 elm.addEventListener('mouseover', function () { 1013 var thisID = elm.getAttribute('aria-controls'); 1014 if(document.querySelector('header')) { 1015 document.querySelector('header').querySelectorAll('.productNavWrapper').forEach(function (Pelm) { 1016 var id = Pelm.getAttribute('id'); 1017 if (thisID === id) { 1018 elm.classList.add('border-b-4', 'border-blue', 'text-blue'); 1019 Pelm.style.display = 'block'; 1020 } else { 1021 Pelm.style.display = 'none'; 1022 if (document.querySelector(`[aria-controls="${id}"]`)) { 1023 document.querySelector(`[aria-controls="${id}"]`).classList.remove('border-b-4', 'border-blue', 'text-blue'); 1024 } 1025 } 1026 }); 1027 } 1028 }); 1029 if(document.querySelector('header')) { 1030 document.querySelector('header').querySelectorAll('.productNavWrapper').forEach(function (elm) { 1031 elm.addEventListener('mouseleave', function (e) { 1032 setTimeout(function () { 1033 var slidingDivWidth = document.querySelector('.slidingDiv').offsetWidth; 1034 if (slidingDivWidth === 0) { 1035 HideHeaderMenu() 1036 } 1037 }, 500); 1038 }) 1039 }); 1040 } 1041 if (document.querySelector('.middleMenu').children[3]) { 1042 document.querySelector('.middleMenu').children[3].addEventListener('mouseover', function () { 1043 HideHeaderMenu(); 1044 }); 1045 } 1046 1047 }); 1048 var activeMenuItem; 1049 var isMouseOutFromMenu = true; 1050 var isMouseOutFromMegaMenu = true; 1051 function hideSlidingBar() { 1052 // $('.slidingBar').find('hr').css({ 'margin-left': '0px' }).width('0px'); 1053 if (isMouseOutFromMegaMenu == true && isMouseOutFromMenu == true) { 1054 document.querySelector('.slidingBar > .slidingDiv').style.width = 0; 1055 1056 } 1057 } 1058 document.querySelectorAll('.slidingBar li').forEach(function (elm) { 1059 elm.addEventListener('mouseover', function () { 1060 executeSlidingBar(elm); 1061 }); 1062 }); 1063 document.querySelectorAll('.productNavWrapper').forEach(function (elm) { 1064 elm.addEventListener('mouseover', function () { 1065 isMouseOutFromMegaMenu = false;
1066 isMouseOutFromMenu = false; 1067 executeSlidingBar(activeMenuItem); 1068 }); 1069 elm.addEventListener('mouseleave', function () { 1070 isMouseOutFromMegaMenu = true; 1071 isMouseOutFromMenu = true; 1072 hideSlidingBar(); 1073 }) 1074 }); 1075 document.querySelectorAll('.slidingBar li').forEach(function (elm) { 1076 elm.addEventListener('mouseover', function () { 1077 isMouseOutFromMegaMenu = false; 1078 isMouseOutFromMenu = false; 1079 }); 1080 elm.addEventListener('mouseleave', function () { 1081 isMouseOutFromMegaMenu = true; 1082 isMouseOutFromMenu = true; 1083 hideSlidingBar(); 1084 setTimeout(function () { 1085 var slidingDivWidth = document.querySelector('.slidingDiv').offsetWidth; 1086 if (slidingDivWidth === 0) { 1087 HideHeaderMenu(); 1088 } 1089 }, 500); 1090 }); 1091 }); 1092 } 1093} 1094function executeSlidingBar(thisElement) { 1095 var dir = document.querySelector('html').getAttribute('dir'); 1096 activeMenuItem = thisElement; 1097 var currentLiWidth = 0; 1098 if (thisElement && !document.querySelector('.wd-header-2-5')) { 1099 currentLiWidth = (thisElement).offsetWidth; 1100 widthAdd = thisElement.offsetLeft + parseInt(window.getComputedStyle(thisElement).paddingLeft) + document.body.scrollLeft; 1101 if (dir === "rtl") { 1102 (thisElement).closest('.slidingBar').querySelector('.slidingDiv').style.cssText = 1103 ` 1104 left: ${widthAdd}px; 1105 width: ${currentLiWidth}px; 1106 `; 1107 } else { 1108 (thisElement).closest('.slidingBar').querySelector('.slidingDiv').style.cssText = ` 1109 left: ${widthAdd}px; 1110 width: ${currentLiWidth}px; 1111 `; 1112 } 1113 } else { 1114 currentLiWidth = (thisElement).offsetWidth; 1115 widthAdd = thisElement.offsetLeft + parseInt(window.getComputedStyle(thisElement).paddingLeft) + document.body.scrollLeft; 1116 (thisElement).closest('.slidingBar').querySelector('.slidingDiv').style.minWidth = `64px`; 1117 if (dir === "rtl") { 1118 (thisElement).closest('.slidingBar').querySelector('.slidingDiv').style.cssText = ` 1119 left: ${widthAdd}px; 1120 visibility: visible; 1121 width: ${currentLiWidth}px; 1122 `; 1123 } else { 1124 (thisElement).closest('.slidingBar').querySelector('.slidingDiv').style.cssText = ` 1125 left: ${widthAdd}px; 1126 visibility: visible; 1127 width: ${currentLiWidth}px; 1128 `; 1129 } 1130 } 1131} 1132function HideHeaderMenu() { 1133 document.querySelector('#productNavStore').classList.add('hidden'); 1134 document.querySelector('#productStore').classList.remove('border-b-4', 'border-blue', 'text-blue'); 1135 document.querySelector('#consumerNavSolutions').classList.add('hidden'); 1136 document.querySelector('#consumerSolutions').classList.remove('border-b-4', 'border-blue', 'text-blue'); 1137 document.querySelector('#businessNavSolutions').classList.add('hidden'); 1138 document.querySelector('#businessSolutions').classList.remove('border-b-4', 'border-blue', 'text-blue'); 1139 document.querySelector('#companyNavWd').classList.add('hidden'); 1140 document.querySelector('#companyWd').classList.remove('border-b-4', 'border-blue', 'text-blue'); 1141} 1142function dynamicHaderHeight() { 1143 if (document.querySelector('.mainContainWrap')) { 1144 var header = document.querySelector('header.header') || ''; 1145 if (header) { 1146 var headerHeight = header.offsetHeight; 1147 header.style.position = 'fixed'; 1148 header.style.top = 0; 1149 document.querySelector('.mainContainWrap').style.marginTop = `${headerHeight}px`; 1150 } 1151 document.querySelector('window').addEventListener('scroll', function () { 1152 headerHeight = header.offsetHeight; 1153 if (!header.classList.contains('header-loaded')) { 1154 header.classList.add('header-loaded'); 1155 } 1156 if (header.classList.contains('header-compressed')) { 1157 document.querySelector('.mainContainWrap').stle.marginTop = headerHeight - 20; 1158 } else { 1159 document.querySelector('.mainContainWrap').stle.marginTop = headerHeight; 1160 } 1161 }); 1162 } 1163} 1164//for mobile 1165function AEMCallMmenuScript() { 1166 document.addEventListener('DOMContentLoaded', function () { 1167 if (document.querySelector(".mobile-nav-bar") != null) { 1168 const menu = new Mmenu(document.querySelector(".mobile-nav-bar")); 1169 const drawer = menu.API; 1170 // menu.remove(); 1171 // const navigator = menu.navigation(); 1172 var mobileMenuFocusElm = document.createElement('a'); 1173 var mobileMenuFocusElmone = document.createElement('a'); 1174 mobileMenuFocusElm.classList.add('mmenu-close-hamburger'); 1175 mobileMenuFocusElm.tabIndex = 0; 1176 mobileMenuFocusElm.href = "#"; 1177 mobileMenuFocusElm.setAttribute('role', 'button'); 1178 1179 mobileMenuFocusElmone.classList.add('mmenu-close-hamburger1'); 1180 mobileMenuFocusElmone.tabIndex = 0; 1181 mobileMenuFocusElmone.href = "#"; 1182 1183 document.querySelector('.mm-menu').prepend(mobileMenuFocusElm); 1184 document.querySelector('.mm-menu').prepend(mobileMenuFocusElmone); 1185 window.addEventListener('click', function (event) { 1186 if (window.innerWidth < 992 && event.target && (event.target.classList.contains('hamburger-menu
1186-bar') || event.target.parentElement.classList.contains('hamburger-menu-bar'))) { 1187 document.querySelector('.hamburger-menu-bar .bar').classList.toggle('animate'); 1188 document.querySelector('.mm-menu--offcanvas').classList.toggle('mMenutoggleWidth'); 1189 document.querySelector('body').classList.toggle('deviceNavView'); 1190 if (document.querySelector('.hamburger-menu-bar .bar').classList.contains('animate')) { 1191 event.preventDefault(); 1192 drawer.open(); 1193 if (document.querySelector('.promo-carousel')) { 1194 document.querySelector('.promo-carousel').style.opacity = 0; 1195 } 1196 // document.querySelector('.mm-ocd--open').style.zIndex = 98; 1197 } else { 1198 event.preventDefault(); 1199 // document.querySelector('.mm-ocd--open').style.zIndex = 150; 1200 if (document.querySelector('.promo-carousel')) { 1201 document.querySelector('.promo-carousel').style.opacity = 1; 1202 } 1203 drawer.close(); 1204 } 1205 } 1206 }); 1207 if (document.querySelector('.mmenu-close-hamburger')) { 1208 document.querySelector('.mmenu-close-hamburger').addEventListener('click', function (e) { 1209 document.querySelector('.hamburger-menu').click(); 1210 }) 1211 } 1212 } 1213 }); 1214} 1215if (!document.querySelector('.wd-header-2-5')) { 1216 AEMCallMmenuScript(); 1217} 1218// for header-2.5 1219if (document.querySelector('.wd-header-2-5 .hamburger-menu')) { 1220 document.addEventListener('click', function (e) { 1221 domClickEventCalled(e); 1222 }); 1223 if (document.querySelector('#searchBTN')) { 1224 document.querySelector('#searchBTN').addEventListener('click', function (e) { 1225 if (document.querySelector(".header-2-5 .dd-button") || document.querySelector(".header-2-5 .dd-button").classList.contains("dropDownOpen")) { 1226 document.querySelector(".header-2-5 .dd-button").classList.remove("dropDownOpen"); 1227 } 1228 domClickEventCalled(e); 1229 }); 1230 } 1231 1232} 1233function domClickEventCalled(e) { 1234 if (e.target.classList.contains('hamburger-menu-bar') || (e.target.parentElement && e.target.parentElement.classList.contains('hamburger-menu-bar'))) { 1235 e.stopPropagation(); 1236 document.querySelector('.mobile-nav-div').classList.remove('hide'); 1237 document.querySelector('.hamburger-menu-bar .bar').classList.toggle('animate'); 1238 document.querySelector('.mobile-nav-bar').classList.toggle('mMenutoggleWidth'); 1239 document.querySelector('body').classList.toggle('mobile-nav-open'); 1240 document.querySelector('body').classList.toggle('deviceNavView'); 1241 } 1242 if (!e.target.classList.contains('openLoginFlyout')) { 1243 if ((e.target.parentElement && !e.target.parentElement.classList.contains('openLoginFlyout')) || e.target.closest('.cartwrapper')) { 1244 if (document.querySelectorAll('.login-flyout').length > 0) { 1245 document.querySelectorAll('.login-flyout').forEach(function (eachflyout) { 1246 eachflyout.classList.add('hidden'); 1247 }); 1248 } 1249 } 1250 } 1251 if (!e.target.classList.contains('mini-cart-trigger')) { 1252 if (!e.target.closest('.mini-cart-trigger')) { 1253 if (!e.target.closest('.cartwrapper')) { 1254 if (!e.target.classList.contains('addToCartBtn')) { 1255 if (!e.target.closest('.addToCartBtn')) { 1256 if (document.querySelector('#openCartModal')) { 1257 document.querySelector('#openCartModal').classList.add('hidden'); 1258 } 1259 } 1260 } 1261 } 1262 } 1263 } 1264 if (!e.target.closest('.tooltip-pct')) { 1265 document.querySelectorAll('.tooltip-pct .chart-tooltip-body').forEach(function (element) { 1266 element.classList.add('hidden'); 1267 element.closest('tr').classList.remove('tooltip-open'); 1268 }) 1269 } 1270 1271} 1272 1273//To Start Chat 1274var chatTriggerElements = document.querySelectorAll('.js-trigger-start-chat');
1275if (chatTriggerElements.length) { 1276 chatTriggerElements.forEach(function (chatTriggerEle) { 1277 1278 chatTriggerEle.setAttribute('tabindex', '0'); 1279 chatTriggerEle.addEventListener('click', e => { 1280 e.preventDefault(); 1281 var chatBtn = document.querySelector('.oda-chat-button'); 1282 if (chatBtn) { 1283 chatBtn.click(); 1284 } else { 1285 // console.log('Genesys Messenger is ready!'); 1286 // Genesys('command', 'Messenger.open', {}); 1287 const chatWindow = document.getElementById("wd-chat-frame") 1288 if(chatWindow) { 1289 if(!chatWindow.hasAttribute("tabindex") || chatWindow.getAttribute("tabindex") === "-1") { 1290 chatWindow.setAttribute("tabindex", "0"); 1291 } 1292 chatWindow.contentWindow.postMessage({ isOpen: true, origin: "wd", focus: true }, "*"); 1293 setTimeout(function() { 1294 chatWindow.focus(); 1295 }, 100); 1296 } 1297 } 1298 }); 1299 }); 1300} 1301// call any function when DOM is ready. 1302document.addEventListener('DOMContentLoaded', function () { 1303 if (document.getElementById("editorial-list-dropdown")) { 1304 document.getElementById("editorial-list-dropdown").addEventListener('change', function () { 1305 let elementId = this.value; 1306 checkIfModalHasForm(elementId); 1307 }); 1308 } 1309 // if publish environment then find all reference component in responsive flexbox component 1310 if (isPublishInstance()) { 1311 var referenceElements = document.querySelectorAll(".responsive-columns-flexbox .reference"); 1312 if (referenceElements && referenceElements.length > 0) { 1313 for (var i = 0; i < referenceElements.length; i++) { 1314 var referenceItem = referenceElements.item(i); 1315 1316 // if this element is the only child and it doesn't have any child nodes 1317 if (referenceItem.parentNode.children.length == 1 && referenceItem.children.length == 0) { 1318 referenceItem.parentNode.style.display = "none"; 1319 } 1320 } 1321 } 1322 } 1323}); 1324// use any function if window.onload is required. 1325// check if anchor tag is internal or external 1326document.addEventListener('DOMContentLoaded', function () { 1327 var origin = window.location.origin; 1328 var host = window.location.host; 1329 var allAnchortags = document.querySelectorAll('a') || ''; 1330 if (allAnchortags.length > 0) {
1331 allAnchortags.forEach(function (eachAnchor) { 1332 var href = eachAnchor.getAttribute('href'); 1333 var target = eachAnchor.getAttribute('target'); 1334 if (href && target && target != "_self" && typeof href != 'undefined' && href.substring(0, 1) != '#' && href.indexOf('http') > -1 && href.indexOf(origin) < 0 && href.indexOf(host) < 0) { 1335 eachAnchor.setAttribute('target', '_blank'); 1336 eachAnchor.setAttribute('rel', 'noreferer, ,noopener'); 1337 1338 } 1339 }); 1340 } 1341}); 1342//Skip To Content in desktop only 1343// creating skip to main content botton and passing some required attributes. 1344if (window.outerWidth >= 992) { 1345 var header = document.querySelector('header.header') || ''; 1346 var skipBtn = ''; 1347 if (header) { 1348 skipBtn = document.createElement('a'); 1349 skipBtn.setAttribute('tabindex', 0); 1350 skipBtn.setAttribute('role', 'link'); 1351 skipBtn.classList.add('skipBTN'); 1352 let skipToContentLabel = "Skip to main content"; 1353 if(document.getElementById("skipToMainContent") 1354 && document.getElementById("skipToMainContent").getAttribute("data-skipLabel")) { 1355 skipToContentLabel = document.getElementById("skipToMainContent").getAttribute("data-skipLabel"); 1356 } 1357 skipBtn.innerHTML = skipToContentLabel; 1358 header.prepend(skipBtn) 1359 } 1360 if (skipBtn.length) { 1361 skipBtn.addEventListener('keyup', function (e) { 1362 if (e.keyCode == 13) { // when Enter key is pressed trigger click event for first <a> tag. 1363 document.querySelector('.skipButton').classList.add('toBeFocused'); 1364 document.querySelector('.skipButton').focus(); 1365 } 1366 }); 1367 } 1368} 1369 1370// loading recaptcha 1371var recaptchaScriptLoaded = false; 1372function loadRecaptchaScript() { 1373 var script = document.createElement('script'); 1374 script.onload = function () { 1375 }; 1376 var commonUtilEle = document.getElementById('commonUtilLoad'); 1377 if (commonUtilEle && commonUtilEle != null) { 1378 recaptchaSitekey = commonUtilEle.getAttribute("data-recaptchaSiteKey"); 1379 } 1380 script.src = 'https://www.google.com/recaptcha/api.js?render=' + recaptchaSitekey; 1381 1382 document.body.appendChild(script); 1383 recaptchaScriptLoaded = true; 1384} 1385var body = document.querySelector('body'); 1386body.classList.add('disabledOutine'); 1387document.addEventListener('mousedown', function () { 1388 body.classList.add('disabledOutine'); 1389}); 1390// keydown event on document. 1391document.addEventListener('keyup', function (e) { 1392 body.classList.add('disabledOutine'); 1393 tabKeyFunctionality(e); 1394 if (e.which === 9 || e.which === 16 || e.shiftKey || e.key === "Enter") { 1395 body.classList.remove('disabledOutine'); 1396 } 1397}); 1398function focusToFirstElement() { 1399 const mainContainer = document.querySelector('.mainContainWrap'); 1400 const inputFocusForSearch = document.querySelector('.mainContainWrap .hero-input input'); 1401 if (document.querySelector('.wd-hero-carousel')) { 1402 var eventMouseEnter = new Event('mouseenter'); 1403 document.querySelector('.wd-hero-carousel').dispatchEvent(eventMouseEnter); 1404 document.querySelector('.wd-hero-carousel .splide__arrow--prev').style.visibility = 'visible'; 1405 document.querySelector('.wd-hero-carousel .splide__arrow--next').style.visibility = 'visible'; 1406 } 1407 if (!mainContainer) { 1408 return; 1409 } 1410 1411 const focusableElements = mainContainer.querySelectorAll('a, input, button, select, li[tabIndex="0"], div[tabIndex="0"] '); 1412 let firstVisibleElement = null; 1413 1414 if (inputFocusForSearch) { 1415 firstVisibleElement = inputFocusForSearch; 1416 } else { 1417 for (const element of focusableElements) { 1418 const computedStyles = getComputedStyle(element); 1419 if (computedStyles.display !== 'none' && !element.classList.contains('hidden')) { 1420 if (!firstVisibleElement && element && !element.closest('#sticky-nav')) { 1421 firstVisibleElement = element; 1422 } 1423 if (element.offsetHeight > 1 && element && !element.closest('#sticky-nav')) { 1424 firstVisibleElement = element; 1425 break; 1426 } 1427 } 1428 } 1429 } 1430 if (firstVisibleElement) { 1431 firstVisibleElement.focus(); 1432 } 1433} 1434 1435document.addEventListener('keydown', function (e) { 1436 tabKeyDownFunctionality(e); 1437 if (e.which === 9) { 1438 body.classList.remove('disabledOutine'); 1439 } 1440}); 1441let footer = document.querySelector('footer');
1442let firstVisibleTag = null; 1443if (footer) { 1444 firstVisibleTag = footer.querySelector('a'); 1445} 1446var megaMenuFirstElement = ''; 1447var megaMenuLastElement = ''; 1448var mobileMenuFirstElement = ''; 1449var PCTFocusBtn = null; 1450var tray = document.querySelector('.wd-compare-tray-wrap'); 1451var emptyTray = document.querySelectorAll('.wd-compare-tray-wrap .tray-item-empty'); 1452var modalTray = document.querySelector('#compare-tray-modal'); 1453var alertModal = document.querySelector('#compare-tray-alert'); 1454var compareTray = null; 1455var anchorButtonToFocus = null; 1456function isHiddenBehindFooter(element) { 1457 if (compareTray) { 1458 var elementRect = element.getBoundingClientRect(); 1459 var trayRect = compareTray.getBoundingClientRect(); 1460 return elementRect.bottom > trayRect.top; 1461 } 1462 return false; 1463} 1464function isHiddenBehindHeader(element) { 1465 var header = document.querySelector('.headerContainer'); 1466 if (header) { 1467 var elementRect = element.getBoundingClientRect(); 1468 var headerRect = header.getBoundingClientRect(); 1469 return elementRect.top < headerRect.bottom; 1470 } 1471 return false; 1472} 1473 1474function scrollIfNecessary(element) { 1475 if (isHiddenBehindFooter(element)) { 1476 let leftFilterContainer = element.closest('.left-filter-container'); 1477 const trayHeight = document.querySelector('.wd-compare-tray-wrap').clientHeight; 1478 const scrollAmount = element.getBoundingClientRect().top + window.scrollY - trayHeight; 1479 window.scrollTo({ top: scrollAmount, behavior: 'smooth' }); 1480 if (leftFilterContainer) { 1481 const scrollAmount = leftFilterContainer.scrollTop + 20; 1482 leftFilterContainer.scrollTop = scrollAmount; 1483 } 1484 } 1485 if (isHiddenBehindHeader(element)) { 1486 const headerHeight = document.querySelector('.headerContainer').clientHeight; 1487 const scrollAmount = element.getBoundingClientRect().top + window.scrollY - headerHeight; 1488 window.scrollTo({ top: scrollAmount, behavior: 'smooth' }); 1489 } 1490} 1491// if focusable element does not have height or with remove tab index. 1492function updateTabIndexForInvisibleElements() { 1493 const focusableSelectors = 'a, button'; 1494 const focusableElements = document.querySelectorAll(focusableSelectors); 1495 1496 focusableElements.forEach(element => { 1497 const style = window.getComputedStyle(element); 1498 const width = parseInt(style.width, 10); 1499 const height = parseInt(style.height, 10); 1500 if (width === 0 || height === 0) { 1501 element.setAttribute('tabindex', '-1'); 1502 } 1503 }); 1504} 1505function tabKeyDownFunctionality(e) { 1506 if (e.target.getAttribute('href') && e.target.getAttribute('href').startsWith('#')) { 1507 PCTFocusBtn = e.target; 1508 } 1509 updateTabIndexForInvisibleElements(); 1510 if (document.querySelectorAll('.leading-loose').length > 0) { 1511 document.querySelectorAll('.leading-loose').forEach(function (elm) { 1512 if (elm.style.display === 'none' && elm.closest('a')) { 1513 elm.closest('a').tabIndex = -1; 1514 } 1515 }); 1516 } 1517 if (e.which === 9 && e.shiftKey && e.target.classList.contains('mmenu-close-hamburger')) { 1518 setTimeout(function () { 1519 e.preventDefault; 1520 document.querySelector('.mmenu-close-hamburger').focus(); 1521 e.stopPropagation(); 1522 }, 100); 1523 } 1524 if ((e.which === 9 && !e.shiftKey && e.target.classList.contains('hamburger-menu') && e.target.querySelector('div').classList.contains('animate'))) { 1525 if (document.querySelector('.mm-panel--opened .mm-listview li a')) { 1526 document.querySelector('.mm-panel--opened .mm-listview li a').focus(); 1527 } 1528 } 1529 if (e.which === 9 && e.shiftKey && !e.target.classList.contains('mob-openLoginFlyout') && e.target.closest('.mm-panel--opened ') && e.target.closest('.mm-panel--opened ').querySelectorAll('.mm-navbar a')[0].tabIndex == '-1' && e.target.parentElement.previousElementSibling === null) { 1530 e.preventDefault(); 1531 document.querySelector('.mmenu-close-hamburger').focus(); 1532 } 1533 1534 if (e.which === 9 && e.shiftKey && !e.target.classList.contains('mob-openLoginFlyout') && e.target.classList.contains('mm-btn--prev') && e.target.tabIndex != '-1' && e.target.parentElement.previousElementSibling === null) { 1535 e.preventDefault(); 1536 document.querySelector('.mmenu-close-hamburger').focus(); 1537 } 1538 if (e.which === 9) { 1539 var lastmobileNavigation; 1540 if (document.querySelector('.nav-brand-logo') && document.querySelector('.nav-brand-logo').lastChild) { 1541 lastmobileNavigation = document.querySelector('.nav-brand-logo').lastChild; 1542 if (e.target.classList === lastmobileNavigation.classList) { 1543 e.preventDefault(); 1544 e.preventDefault(); 1545 document.querySelector('.mmenu-close-hamburger').focus(); 1546 } 1547 1548 } 1549 1550 const mapImage = document.querySelector('img[alt="CareersLocations-Map_Fixed"]'); 1551 const videoElement = document.querySelector('.sbgv-video'); 1552 if (mapImage) { 1553 // Create a MutationObserver to watch for class attribute changes 1554 const observer = new MutationObserver((mutationsList) => { 1555 for (const mutation of mutationsList) { 1556 if (mutation.type === 'attributes' && mutation.attributeName === 'class') { 1557 if (mapImage.classList.contains('lazyloaded')) { 1558 videoElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); 1559 observer.disconnect(); // Stop observing after the image has loaded 1560 } 1561 } 1562 } 1563 }); 1564 // Start observing the mapImage for class attribute changes 1565 observer.observe(mapImage, { attributes: true }); 1566 } else { 1567 console.error('Image element not found'); 1568 } 1569 1570 if (!e.shiftKey && e.target.closest('li') && !e.target.closest('li').classList.contains('nav-brand-logo') && e.target.closest('li').nextElementSibling === null && document.querySelector('.mm-menu') && document.querySelector('.mm-menu').classList.contains('mm-menu--opened')) { 1571 e.preventDefault(); 1572 document.querySelector('.mmenu-close-hamburger').focus(); 1573 } 1574 var PCTTray = document.querySelector('.wd-compare-tray-wrap'); 1575 if (PCTTray && !e.shiftKey && e.target.classList.contains('compare-tray-btn') && !PCTTray.classList.contains('tray-open') && firstVisibleTag) { 1576 e.preventDefault(); 1577 firstVisibleTag.focus(); 1578 } 1579 if (firstVisibleTag) { 1580 firstVisibleTag.addEventListener('keydown', function (event) { 1581 if (event.key === "Tab" && event.shiftKey) { 1582 var itemTray = document.querySelector('.wd-compare-tray-wrap') 1583 var splicedTagList = [] 1584 if (itemTray) { 1585 event.preventDefault(); 1586 event.stopImmediatePropagation(); 1587 itemTray.querySelector('.compare-tray-btn').focus(); 1588 } 1589 } 1590 }); 1591 } 1592 // ADA for ODA chatBot 1593 if (document.querySelector('.oda-chat-wrapper') && !e.shiftKey) { 1594 if (e.target.classList.contains('oda-chat-button-upload')) { 1595 document.querySelector('body').classList.remove('disabledOutine'); 1596 if (document.querySelector('.oda-chat-header #agent-button')) { 1597 e.preventDefault(); 1598 document.querySelector('.oda-chat-header #agent-button').focus(); 1599 } 1600 } 1601 if (e.target.id === 'chat-bot-Ybut') { 1602 e.preventDefault(); 1603 document.querySelector('#chat-bot-confbtn #chat-bot-Nbut').focus(); 1604 } 1605 if (e.target.id === 'chat-bot-Nbut') { 1606 e.preventDefault(); 1607 document.querySelector('#chat-bot-confbtn #chat-bot-Ybut').focus(); 1608 } 1609 } 1610 // for shit and tab reverse direction. 1611 if (document.querySelector('.oda-chat-wrapper') && e.shiftKey) { 1612 if (e.target.classList.contains('oda-chat-button-upload')) { 1613 e.preventDefault(); 1614 document.querySelector('.oda-chat-button-send').focus(); 1615 } 1616 if (e.target.id === 'agent-button') { 1617 e.preventDefault(); 1618 document.querySelector('.oda-chat-button-upload').focus(); 1619 } 1620 if (e.target.id === 'chat-bot-Ybut') { 1621 e.preventDefault(); 1622 document.querySelector('#chat-bot-confbtn #chat-bot-Nbut').focus(); 1623 } 1624 if (e.target.id === 'chat-bot-Nbut') { 1625 e.preventDefault(); 1626 document.querySelector('#chat-bot-confbtn #chat-bot-Ybut').focus(); 1627 } 1628 } 1629 } 1630 if (e.which === 13 || e.keyCode === 32) { 1631 if (e.target.classList.contains('pointer-events-none')) { 1632 e.preventDefault(); 1633 e.stopImmediatePropagation(); 1634 } 1635 // when we have product card and user press enter or space. 1636 if (e.target.closest('.product-card') && !e.target.closest('.wd-modal')) { 1637 e.stopPropagation(); 1638 e.target.click(); 1639 setTimeout(() => { 1640 e.target.closest('.product-card').querySelector('.wd-modal .wd-modal-close').focus(); 1641 }, 200); 1642 } 1643 // ADA for ODA chatBot 1644 if (document.querySelector('.oda-chat-wrapper')) { 1645 if (e.target.id === 'close-button') { 1646 setTimeout(() => { 1647 if (document.querySelector('#chat-bot-confbtn #chat-bot-Ybut')) { 1648 document.querySelector('#chat-bot-confbtn #chat-bot-Ybut').focus(); 1649 } 1650 }, 500); 1651 } 1652 } 1653 } 1654} 1655// this function need to be remove for cleanup activity. 1656function findLastVisibleFocusableElement() { 1657 const mainContainer = document.querySelector('.mainContainWrap'); 1658 const allElements = mainContainer.querySelectorAll('a, button ,li[tabindex="0"], select'); 1659 let lastFocusableElement = null 1660 function hasPositiveHeight(element) { 1661 if (element && element.clientHeight > 0) { 1662 lastFocusableElement = element; 1663 } 1664 } 1665 const focusableElements = Array.from(allElements).filter(element => { 1666 if (!hasPositiveHeight(element)) { 1667 return false;
1668 } 1669 1670 }); 1671 if (lastFocusableElement) { 1672 lastFocusableElement.focus(); 1673 scrollIfNecessary(lastFocusableElement) 1674 } 1675} 1676function checkModalTray() { 1677 setTimeout(function () { 1678 var tray = document.querySelector('.wd-compare-tray-wrap'); 1679 if (tray && tray.classList.contains('tray-open')) { 1680 if (tray.querySelector('button')) { 1681 tray.querySelector('button').focus(); 1682 } 1683 } 1684 }, 500) 1685} 1686var mystryCount = 0; 1687var NavHeight = -1; // variable only for search support 1688function checkforMystrySaving(event) { 1689 var mysterySavingsModal = document.querySelector('#mystery-savings-modal') || ''; 1690 if (mysterySavingsModal && event.keyCode === 9) { 1691 if (!mysterySavingsModal.classList.contains('hidden')) { 1692 mystryCount++; 1693 mysterySavingsModal.querySelector('button.wd-modal-close').focus(); 1694 } 1695 } 1696} 1697function tabKeyFunctionality(e) { 1698 // checking for mystry saving 1699 1700 if (mystryCount === 0) { 1701 checkforMystrySaving(e); 1702 } 1703 //checking if focusable element is behind compare tray or header. 1704 compareTray = document.querySelector('.wd-compare-tray-wrap'); 1705 if (compareTray && e.target && e.key === "Tab" && !e.shiftKey && !e.target.closest('.wd-compare-tray-wrap')) { 1706 setTimeout(function () { 1707 // get the currently focused element 1708 var focusedElement = document.activeElement; 1709 scrollIfNecessary(focusedElement); 1710 }, 0); 1711 } 1712 if (compareTray && e.target && e.key === "Tab" && e.shiftKey && !e.target.closest('.wd-compare-tray-wrap')) { 1713 setTimeout(function () { 1714 // get the currently focused element 1715 var focusedElement = document.activeElement; 1716 scrollIfNecessary(focusedElement); 1717 }, 0); 1718 } 1719 function checkAccordion() { 1720 var accordionContents = document.querySelectorAll('.accordion-content'); 1721 if (accordionContents.length) { 1722 accordionContents.forEach(function (content) { 1723 if (content.classList.contains('hidden') && !document.querySelector('.region-selector')) { 1724 var anchorTags = content.querySelectorAll('a'); 1725 var buttons = content.querySelectorAll('button'); 1726 if (anchorTags) { 1727 anchorTags.forEach(function (anchor) { 1728 anchor.setAttribute('tabindex', -1); 1729 }); 1730 } 1731 if (buttons) { 1732 buttons.forEach(function (button) { 1733 button.setAttribute('tabindex', -1); 1734 }); 1735 } 1736 } else { 1737 var anchorTags = content.querySelectorAll('a'); 1738 var buttons = content.querySelectorAll('button'); 1739 if (anchorTags) { 1740 anchorTags.forEach(function (anchor) { 1741 anchor.setAttribute('tabindex', 0); 1742 }); 1743 } 1744 if (buttons) { 1745 buttons.forEach(function (button) { 1746 button.setAttribute('tabindex', 0); 1747 }); 1748 } 1749 } 1750 }); 1751 } 1752 } 1753 checkAccordion(); 1754 1755 var megaNavigation = document.querySelectorAll('.middleMenu li[id]') || ''; 1756 var mmBtnPrev = document.querySelectorAll('.mm-btn--prev') || ''; 1757 // varients of the prodcuts 1tb, 2tb, 5tb etc. 1758 if (megaNavigation.length > 0 && e.target && e.target.closest('.middleMenu')) { 1759 var thisID = e.target.parentElement ? e.target.parentElement.getAttribute('aria-controls') : null; 1760 var megaNavConatiner = document.querySelector(`#${thisID}`) || ''; 1761 if (megaNavConatiner) { 1762 megaMenuFirstElement = megaNavConatiner.querySelectorAll('a')[0]; 1763 megaMenuLastElement = megaNavConatiner.querySelectorAll('a')[megaNavConatiner.querySelectorAll('a').length - 1]; 1764 } 1765 } 1766 if (document.querySelector('.wd-header-2-5')) { 1767 if (megaMenuFirstElement || megaMenuLastElement) { 1768 megaMenuFirstElement.addEventListener('keydown', function (e) { 1769 if ((e.which === 9 && e.shiftKey)) { 1770 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1771 } 1772 }); 1773 megaMenuLastElement.addEventListener('keydown', function (e) { 1774 1775 if (e.keyCode != 13 && e.keyCode == 9 && !e.shiftKey) { 1776 if (e.target.closest('.productNavWrapper')) { 1777 var id = e.target.closest('.productNavWrapper').getAttribute('id'); 1778 if (document.querySelector(`[aria-controls=${id}]`) && document.querySelector(`[aria-controls=${id}]`).nextElementSibling.hasAttribute('id') && document.querySelector(`[aria-controls=${id}]`).nextElementSibling.classList.contains('mainMenuItem')) { 1779 e.preventDefault(); 1780 e.stopPropagation(); 1781 document.querySelector(`[aria-controls=${id}]`).nextElementSibling.querySelector('button').focus(); 1782 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1783 } else { 1784 if (document.querySelector('.login-btn-trigger button')) { 1785 e.preventDefault(); 1786 e.stopPropagation(); 1787 document.querySelector('.login-btn-trigger button').focus(); 1788 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1789 } else { 1790 if (document.querySelector('.mySupport-wrap button')) { 1791 e.preventDefault(); 1792 e.stopPropagation(); 1793 document.querySelector('.mySupport-wrap button').focus(); 1794 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1795 } else { 1796 if (document.querySelector('.btn-search')) { 1797 document.querySelector('.btn-search').focus(); 1798 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1799 } 1800 } 1801 } 1802 1803 } 1804 } 1805 1806 } else { 1807 if (e.keyCode == 13) { 1808 e.target.click(); 1809 } 1810 if (e.keyCode == 9 && e.shiftKey) { 1811 if (e.target.parentElement) { 1812 if (e.target && e.target.parentElement && e.target.parentElement.previousElementSibling && e.target.parentElement.previousElementSibling.querySelector('a') && !e.target.parentElement.previousElementSibling.querySelector('a').classList.contains('hidden')) 1813 e.target.parentElement.previousElementSibling.querySelector('a').focus(); 1814 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1815 } 1816 } 1817 } 1818 }); 1819 } 1820 } else if (megaMenuFirstElement || megaMenuLastElement) { 1821 megaMenuFirstElement.addEventListener('keydown', function (e) { 1822 if ((e.which === 9 && e.shiftKey)) { 1823 var id = e.target.closest('.productNavWrapper').getAttribute('id'); 1824 document.querySelector(`.middleMenu [aria-controls=${id}]`).focus(); 1825 } 1826 }); 1827 megaMenuLastElement.addEventListener('keydown', function (e) { 1828 if (e.keyCode != 13 && e.keyCode == 9 && !e.shiftKey) { 1829 if (e.target.closest('.productNavWrapper')) { 1830 var id = e.target.closest('.productNavWrapper').getAttribute('id'); 1831 if (document.querySelector(`[aria-controls=${id}]`) && document.querySelector(`[aria-controls=${id}]`).nextElementSibling.hasAttribute('id')) { 1832 document.querySelector(`[aria-controls=${id}]`).focus(); 1833 } else { 1834 if (document.querySelector('.btn-search')) { 1835 document.querySelector('.btn-search').focus(); 1836 } else { 1837 if (document.querySelector('.btn-search')) { 1838 document.querySelector('.btn-search').focus(); 1839 document.querySelector('.middleMenu .slidingDiv').style.visibility = 'hidden'; 1840 } 1841 } 1842 } 1843 } 1844 1845 } else { 1846 if (e.keyCode == 13) { 1847 e.target.click(); 1848 } 1849 } 1850 }); 1851 } 1852 var productVarients = document.querySelectorAll('ul.variant-axis-default li') || ''; 1853 if (e.target && e.target.closest('.header-2-5')) { 1854 if(document.querySelectorAll('.header-2-5 .dd-menu li').length > 0){ 1855 var lastElement = document.querySelectorAll('.header-2-5 .dd-menu li')[document.querySelectorAll('.header-2-5 .dd-menu li').length - 1]; 1856 lastElement.addEventListener('keydown', function (e) { 1857 var clickEvent = new Event('click'); 1858 if (e.target) { 1859 e.target.closest('.header-2-5').querySelector('.dd-button').dispatchEvent(clickEvent); 1860 } 1861 return false;
1862 }) 1863 } 1864 } 1865 if (productVarients.length > 0) { 1866 productVarients.forEach(function (elm) { 1867 if (elm.querySelector('button') || elm.querySelector('a')) { 1868 elm.removeAttribute('tabindex'); 1869 if (elm.querySelector('button')) { 1870 elm.querySelector('button').setAttribute('tabindex', 0); 1871 } 1872 if (elm.querySelector('a')) { 1873 elm.querySelector('a').setAttribute('tabindex', 0); 1874 } 1875 } else { 1876 elm.setAttribute('tabindex', 0); 1877 } 1878 }); 1879 } 1880 if (e.keyCode === 9) { 1881 var productBanner = document.querySelector('.product-banner') || ''; 1882 var AllListItems = document.querySelectorAll('.relatedProduct li'); 1883 if (AllListItems.length > 0) { 1884 AllListItems.forEach(function (elm) { 1885 if (elm) { 1886 if (elm.querySelector('button')) { 1887 elm.removeAttribute('tabindex'); 1888 elm.querySelector('button').setAttribute('tabindex', 0); 1889 } else { 1890 if (elm.querySelector('a')) { 1891 elm.removeAttribute('tabindex'); 1892 elm.querySelector('a').setAttribute('tabindex', 0); 1893 } else { 1894 elm.setAttribute('tabindex', 0); 1895 } 1896 } 1897 } 1898 }); 1899 } 1900 if (productBanner) { 1901 var listItems = productBanner.querySelectorAll('#updateProductGallery .vertical-carousel-single li.splide__slide[id].is-active.is-visible'); 1902 if (listItems.length > 0) { 1903 listItems.forEach(function (elm) { 1904 if (elm) { 1905 if (elm.querySelector('button')) { 1906 elm.removeAttribute('tabindex'); 1907 elm.querySelector('button').setAttribute('tabindex', 0); 1908 } else { 1909 elm.setAttribute('tabindex', 0); 1910 } 1911 } 1912 }); 1913 } 1914 } 1915 if (document.querySelector('.searchSummaryViewInput') && document.querySelector('.searchSummaryViewInput').value == "") { 1916 document.querySelector('.svClearInput').setAttribute("tabindex", "-1"); 1917 document.querySelector('.searchSummaryViewInput').setAttribute("tabindex", "-1"); 1918 } else { 1919 if (document.querySelector('.svClearInput')) { 1920 document.querySelector('.svClearInput').removeAttribute('tabindex'); 1921 document.querySelector('.searchSummaryViewInput').setAttribute("tabindex", "0"); 1922 } 1923 } 1924 if (!e.target.closest('.productNavWrapper')) { 1925 document.querySelectorAll('.productNavWrapper').forEach(function (elm) { 1926 elm.classList.add('hidden'); 1927 }); 1928 } 1929 e.target.classList.add('focusOutline'); 1930 if (document.querySelectorAll('.wd-modal').length > 0) { 1931 document.querySelectorAll('.wd-modal').forEach(function (eachModal) { 1932 if (!eachModal.classList.contains('hidden')) { 1933 var inputs = eachModal.querySelectorAll('select, input, textarea, button, a, .cursor-pointer'); 1934 var firstInput = inputs[0]; 1935 var lastInput = inputs[inputs.length - 1]; 1936 if (!e.target.closest('.wd-modal')) { 1937 firstInput.focus() 1938 } 1939 lastInput.addEventListener('keydown', function (e) { 1940 if ((e.which === 9 && !e.shiftKey)) { 1941 e.preventDefault(); 1942 firstInput.focus(); 1943 } 1944 }); 1945 firstInput.addEventListener('keydown', function (e) { 1946 if ((e.which === 9 && e.shiftKey)) { 1947 e.preventDefault(); 1948 lastInput.focus(); 1949 } 1950 }); 1951 } 1952 }); 1953 } 1954 if (e.target.classList.contains('wd-modal-close')) { 1955 if (event.key === "Tab") { 1956 if (!event.shiftKey) { 1957 if (e.target.closest('.wd-modal-content') && e.target.closest('.wd-modal-content').querySelector('iframe')) { 1958 e.target.closest('.wd-modal-content').querySelector('iframe').focus(); 1959 if ( document.querySelector('#updateProductGallery .wd-modal .wd-modal-content .wd-modal-close')) { 1960 document.querySelector('#updateProductGallery .wd-modal .wd-modal-content .wd-modal-close').classList.remove('focusOutline'); 1961 } 1962 1963 } 1964 } 1965 } 1966 1967 } 1968 1969 var herVideo = document.querySelector('#hero-video .wd-modal'); 1970 if (herVideo && !herVideo.classList.contains('hidden')) { 1971 herVideo.querySelector('.wd-modal-close').focus(); 1972 } 1973 1974 if (e.target.classList.contains('splide__slide') && document.querySelector('#updateProductGallery') && document.querySelector('#updateProductGallery .wd-modal') && !document.querySelector('#updateProductGallery .wd-modal').classList.contains('hidden')) { 1975 document.querySelector('#updateProductGallery .wd-modal .wd-modal-content button').focus(); 1976 document.querySelector('#updateProductGallery .wd-modal .wd-modal-content button').classList.add('focusOutline'); 1977 } 1978 if (document.querySelector('.splide__slide') && document.querySelector('.rd-main-carousel')) { 1979 if (document.querySelector('.product-img-carousel .rd-main-carousel .splide__slide.is-active.is-visible')) { 1980 document.querySelector('.product-img-carousel .rd-main-carousel .splide__slide.is-active.is-visible').tabIndex = '0'; 1981 } 1982 if (document.querySelector('.product-img-carousel .rd-main-carousel .splide__slide')) { 1983 document.querySelectorAll('.product-img-carousel .rd-main-carousel .splide__slide').forEach(function (eachSlide) { 1984 if (!eachSlide.classList.contains('is-active')) { 1985 eachSlide.tabIndex = '-1'; 1986 } 1987 }) 1988 } 1989 } 1990 if (e.target && e.target.classList.contains('dd-button')) { 1991 if (!document.querySelector('.dd-button').classList.contains('dropDownOpen')) { 1992 var dd_anchors = document.querySelectorAll('.dd-menu li a'); 1993 if (dd_anchors.length > 0) {
1994 dd_anchors.forEach(function (elm) { 1995 elm.setAttribute('tabindex', -1); 1996 }) 1997 } 1998 } 1999 } else { 2000 if (e.target && !e.target.closest('.dd-menu')) { 2001 if (document.querySelector('.dd-button')) { 2002 document.querySelector('.dd-button').classList.remove('dropDownOpen'); 2003 var dd_anchors = document.querySelectorAll('.dd-menu li a'); 2004 if (dd_anchors.length > 0) { 2005 dd_anchors.forEach(function (elm) { 2006 elm.setAttribute('tabindex', -1); 2007 }) 2008 } 2009 } 2010 } 2011 } 2012 var subNavLastElm; 2013 var productDetailsLastElm; 2014 var productDetailsFirstElm; 2015 var prodcutCarouselLastElm; 2016 var prodcutCarouselfirstElm; 2017 var outsideProductElm; 2018 if (e.target && e.target.closest('#sticky-nav')) { 2019 var lastElm = []; 2020 if (document.querySelectorAll('#sticky-nav a').length > 0) 2021 document.querySelectorAll('#sticky-nav a').forEach(function (elm) { 2022 if (!elm.closest('div').classList.contains('hidden')) { 2023 lastElm.push(elm); 2024 } 2025 }); 2026 subNavLastElm = lastElm[lastElm.length - 1]; 2027 if (subNavLastElm) { 2028 subNavLastElm.addEventListener('keydown', function (e) { 2029 if (e.keyCode === 9 && !e.shiftKey) { 2030 if (document.querySelector('.productBannerApp .product-details a')) { 2031 document.querySelector('.productBannerApp .product-details .pdpBreadcrumbView a[data-track-type="breadcrumb"]').focus(); 2032 productDetailsFirstElm = document.querySelector('.productBannerApp .product-details .pdpBreadcrumbView a'); 2033 setTimeout(function () { 2034 productDetailsFirstElm.focus(); 2035 if (productDetailsFirstElm) { 2036 productDetailsFirstElm.addEventListener('keydown', function (e) { 2037 if (e.keyCode === 9 && e.shiftKey) { 2038 setTimeout(function () { 2039 subNavLastElm.focus(); 2040 }, 100); 2041 } 2042 }); 2043 } 2044 }, 100); 2045 } 2046 } 2047 }); 2048 } 2049 } 2050 if (e.target && e.target.closest('.product-details')) { 2051 if (document.querySelectorAll('.productBannerApp .product-details .store-product-wtb a, .productBannerApp .product-details .store-product-wtb button').length > 0) { 2052 productDetailsLastElm = document.querySelectorAll('.productBannerApp .product-details .store-product-wtb a, .productBannerApp .product-details .store-product-wtb button ')[document.querySelectorAll('.productBannerApp .product-details .store-product-wtb a, .productBannerApp .product-details .store-product-wtb button ').length - 1]; 2053 } 2054 if (productDetailsLastElm) { 2055 productDetailsLastElm.addEventListener('keydown', function (e) { 2056 if (e.keyCode === 9 && !e.shiftKey) { 2057 if (document.querySelector('.productBannerApp .product-details') && document.querySelector('.productBannerApp .product-details').previousElementSibling) { 2058 document.querySelector('.productBannerApp .product-details').previousElementSibling.querySelectorAll('#updateProductGallery div.store-product-image').forEach(function (elm) { 2059 if (!elm.classList.contains('hidden')) { 2060 setTimeout(function () { 2061 prodcutCarouselfirstElm = elm.querySelector('a, button, li[tabindex="0"]'); 2062 if (prodcutCarouselfirstElm && !document.querySelector('.pdp-redesign')) { 2063 prodcutCarouselfirstElm.addEventListener('keydown', function (e) { 2064 if (e.keyCode === 9 && e.shiftKey) { 2065 setTimeout(function () { 2066 productDetailsLastElm.focus() 2067 }, 100); 2068 } 2069 }); 2070 } 2071 }, 100); 2072 if (elm.querySelectorAll('.vertical-carousel li.is-visible')[elm.querySelectorAll('.vertical-carousel li.is-visible').length - 1]) { 2073 prodcutCarouselLastElm = elm.querySelectorAll('.vertical-carousel li.is-visible')[elm.querySelectorAll('.vertical-carousel li.is-visible').length - 1]; 2074 } else if (elm.querySelectorAll('.vertical-carousel-single li.is-visible')[elm.querySelectorAll('.vertical-carousel-single li.is-visible').length - 1]) { 2075 prodcutCarouselLastElm = elm.querySelectorAll('.vertical-carousel-single li.is-visible')[elm.querySelectorAll('.vertical-carousel-single li.is-visible').length - 1]; 2076 } else { 2077 if (elm.querySelectorAll('.vertical-carousel li.is-visible').length > 0) { 2078 prodcutCarouselLastElm = elm.querySelectorAll('.vertical-carousel li.is-visible')[elm.querySelectorAll('.vertical-carousel li.is-visible').length - 1].previousElementSibling; 2079 } 2080 } 2081 } 2082 }) 2083 } 2084 if (prodcutCarouselLastElm) { 2085 prodcutCarouselLastElm.addEventListener('keydown', function (e) { 2086 if (e.keyCode === 9 && !e.shiftKey) { 2087 if (e.target.closest('.productBannerWrapper')) { 2088 if (e.target.closest('.productBannerWrapper').nextElementSibling) { 2089 setTimeout(function () { 2090 var allSiblings = getNextSiblings(e.target.closest('.productBannerWrapper')); 2091 var splicedList = [] 2092 allSiblings.map((eachElm) => { 2093 if (eachElm.offsetHeight > 0) { 2094 outsideElmList = eachElm.querySelectorAll('a, button, li[tabindex="0"]'); 2095 for (let nodeItem = 0; nodeItem < outsideElmList.length; nodeItem++) { 2096 if (outsideElmList[nodeItem].offsetHeight > 0) { 2097 splicedList.push(outsideElmList[nodeItem]); 2098 } 2099 } 2100 outsideProductElm = splicedList[0] 2101 outsideProductElm.focus(); 2102 return false 2103 } 2104 }) 2105 outsideProductElm.addEventListener('keydown', function (e) { 2106 if (e.keyCode === 9 && e.shiftKey) { 2107 prodcutCarouselLastElm.focus(); 2108 } 2109 }); 2110 }, 100); 2111 } 2112 } 2113 } 2114 }); 2115 } 2116 function getNextSiblings(element) { 2117 var siblings = []; 2118 while (element.nextSibling) { 2119 element = element.nextSibling; 2120 if (element.nodeType === 1) { 2121 siblings.push(element); 2122 } 2123 } return siblings; 2124 } 2125 } 2126 }); 2127 2128 } 2129 } 2130 var PCTTray = document.querySelector('.wd-compare-tray-wrap'); 2131 if (e.target.classList.contains('compare-link-clp') && PCTTray && PCTTray.classList.contains('tray-open')) { 2132 var top = e.target.offsetTop; 2133 scrollToSmoothly(top, 200); 2134 PCTTray.classList.remove('tray-open') 2135 } 2136 if (!e.target.closest('.wd-compare-tray-wrap') && PCTTray) { 2137 PCTTray.classList.remove('tray-open'); 2138 } 2139 // code only for search vue-migration 2140 if (e.target && e.target.classList.contains('redirectToUrl')) { 2141 if (e.target.closest('.splide__list')) { 2142 var container = document.querySelector('.storeSearchResult'); 2143 if (container) { 2144 var elementsWithTabIndex = container.querySelectorAll('[tabindex]'); 2145 elementsWithTabIndex.forEach(function (element) { 2146 element.setAttribute('tabindex', '0'); 2147 }); 2148 } 2149 if (NavHeight < 0) {
2150 NavHeight = e.target.closest('.splide__list').offsetHeight; 2151 } 2152 var AllLis = e.target.closest('.splide__list').querySelectorAll('.splide__slide'); 2153 if (AllLis.length > 0) { 2154 AllLis.forEach((eachLi) => { 2155 eachLi.querySelector('.storeSearchWrapper').style.height = `${NavHeight}px`; 2156 eachLi.querySelector('.productCTAwrap').classList.remove('productCTAwrapShow'); 2157 }); 2158 } 2159 e.target.closest('.splide__slide').querySelector('.productCTAwrap').classList.add('productCTAwrapShow'); 2160 e.target.closest('.splide__slide').querySelector('.storeSearchWrapper').style.height = ''; 2161 2162 } 2163 } else { 2164 if (document.querySelector('#storeSearchResult-list') && NavHeight && !e.target.closest('.splide__list')) { 2165 var AllLis = document.querySelectorAll('#storeSearchResult-list.splide__list .splide__slide'); 2166 AllLis.forEach((eachLi) => { 2167 eachLi.querySelector('.storeSearchWrapper').style.height = `${NavHeight}px`; 2168 eachLi.querySelector('.productCTAwrap').classList.remove('productCTAwrapShow'); 2169 }); 2170 } 2171 } 2172 2173 if (!e.target.closest('.hero-input')) { 2174 if (document.querySelector('.ui-autocomplete')) { 2175 let list = document.querySelectorAll('.ui-autocomplete li'); 2176 if (list.length) { 2177 list.forEach((elm) => { 2178 if (elm) elm.style.display = 'none'; 2179 }); 2180 } 2181 } 2182 } 2183 if (document.querySelector('.tooltiptrigger')) { 2184 if (document.querySelectorAll('.tooltipbox').length > 0) { 2185 document.querySelectorAll('.tooltipbox').forEach(function (elm) { 2186 elm.style.display = "none"; 2187 }); 2188 } 2189 } 2190 // predictive seach accessibility 2191 if ((e.key === "Tab" || e.key === "Shift") && !e.target.closest('.predictive-search-form') && !e.target.closest('.support-search') && !e.target.closest('.nav-container') && !e.target.closest('.dd-menu') && !e.target.closest('.login-flyout') && !e.target.closest('.cartwrapper')) { 2192 if (document.querySelector(".search-collapse")) { 2193 document.querySelector(".search-collapse").click(); 2194 } 2195 } 2196 // Function to find the first focusable anchor element for predictive search 2197 function findFirstFocusableAnchor(container) { 2198 const anchors = container.querySelectorAll('a'); 2199 for (let anchor of anchors) { 2200 if (!anchor.hasAttribute('disabled') && anchor.getAttribute('tabindex') !== '-1') { 2201 return anchor; 2202 } 2203 } 2204 return null; 2205 } 2206 // predictive container and the target input element 2207 var predictiveContainer = document.querySelector('#predictiveSearchContainer'); 2208 var targetInput = document.querySelector('#predictiveSearchNavForm input.searchSummaryViewInput'); 2209 2210 if (predictiveContainer && targetInput) { 2211 const firstFocusableAnchor = findFirstFocusableAnchor(predictiveContainer); 2212 if (firstFocusableAnchor) { 2213 firstFocusableAnchor.addEventListener('keydown', function (event) { 2214 if (event.key === 'Tab' && event.shiftKey) { 2215 event.preventDefault(); 2216 targetInput.focus(); 2217 } 2218 }); 2219 } 2220 } 2221 } 2222 if (e.keyCode === 13 || e.keyCode === 32) { 2223 e.stopPropagation() 2224 e.preventDefault(); 2225 checkAccordion(); 2226 // for green promo 2227 if (e.target.closest('.product-promo')) { 2228 e.target.click(); 2229 } 2230 // clicking on product baner image 2231 if (e.target.classList.contains('is-active') && e.target.closest('.rd-main-carousel')) { 2232 e.target.click(); 2233 } 2234 // clicking on PDP color variant. 2235 if (e.target.closest('.variant-category-container') && e.target.querySelector('img')) { 2236 e.target.querySelector('img').click(); 2237 } 2238 // clicking on find a reseller 2239 if (e.target.closest('.store-product-wtb') && e.target.classList.contains('wtbBtbwWithIcon')) { 2240 e.target.click(); 2241 } 2242 2243 // sign in button inside singIn modal 2244 if (e.target.classList.contains('.signInBTN')) { 2245 e.target.click(); 2246 } 2247 //for editorial listing component 2248 if (e.target.classList.contains('accordion-svg-unique-element')) { 2249 e.target.click(); 2250 } 2251 // mystery saving submitting form 2252 if (document.querySelector('#mystery-savings-modal') && !document.querySelector('#mystery-savings-modal').classList.contains('hidden')) { 2253 setTimeout(() => { 2254 document.querySelector('#mystery-savings-modal').querySelector('button.wd-modal-close').focus(); 2255 }, 500); 2256 } 2257 // code only for search vue-migration 2258 if (e.target && e.target.classList.contains('redirectToUrl')) { 2259 e.target.click(); 2260 } 2261 if (e.target.type == "checkbox") { 2262 e.target.click(); 2263 } 2264 if (e.target.classList.contains('compare-link-clp')) { 2265 PCTFocusBtn = e.target; 2266 } 2267 if (e.target && e.target.classList.contains('dd-button')) { 2268 if (e.keyCode === 32) { 2269 e.target.click(); 2270 } 2271 if (document.querySelector('.dd-button').classList.contains('dropDownOpen')) { 2272 var dd_anchors = document.querySelectorAll('.dd-menu li a'); 2273 if (dd_anchors.length > 0) {
2274 dd_anchors.forEach(function (elm) { 2275 elm.setAttribute('tabindex', 0); 2276 }) 2277 } 2278 } 2279 } 2280 if (e.target.classList.contains('mmenu-close-hamburger')) { 2281 e.preventDefault(); 2282 document.querySelector('.hamburger-menu').click(); 2283 } 2284 if (e.target.classList.contains('skipBTN')) { 2285 focusToFirstElement(); 2286 } 2287 if (megaNavigation.length > 0 && e.target && e.target.closest('.middleMenu')) { 2288 var thisID = e.target.getAttribute('aria-controls'); 2289 var megaNavConatiner = document.querySelector(`.productNavWrapper#${thisID}`) || ''; 2290 if (megaNavConatiner) { 2291 megaNavConatiner.style.display = 'block'; 2292 megaNavConatiner.classList.remove('hidden'); 2293 setTimeout(function () { 2294 megaNavConatiner.querySelectorAll('a')[0].focus(); 2295 megaMenuFirstElement = megaNavConatiner.querySelectorAll('a')[0]; 2296 }, 500); 2297 } 2298 } 2299 if (e.target.classList.contains('shopAccountLogin') || (e.target.closest('.shopAccountLogin') && e.target.closest('.shopAccountLogin').classList.contains('shopAccountLogin'))) { 2300 var clickEvent = new Event('click'); 2301 e.target.dispatchEvent(clickEvent); 2302 setTimeout(function () { 2303 if (document.querySelector('#login-modal-win')) { 2304 document.querySelector('#login-modal-win').querySelector('button').focus(); 2305 } 2306 }, 300); 2307 } 2308 if (e.target.classList.contains('openLoginFlyout') || e.target.closest('.openLoginFlyout')) { 2309 setTimeout(function () { 2310 document.querySelector('.login-flyout').querySelector('button').focus(); 2311 }, 300); 2312 } 2313 if (e.target.classList.contains('wd-modal-close')) { 2314 setTimeout(function () { 2315 if (!document.querySelector('.login-flyout').classList.contains('hidden')) { 2316 document.querySelector('.login-flyout').querySelector('button').focus(); 2317 } 2318 }, 300); 2319 } 2320 // when enter key pressed on splice video sub-nav button 2321 if (e.target.classList.contains('play-btn') && e.target.closest('.splide--nav')) { 2322 setTimeout(function () { 2323 document.querySelector('.product-banner #updateProductGallery .splide--draggable .splide__slide.is-active button').focus(); 2324 document.querySelector('.product-banner #updateProductGallery .splide--draggable .splide__slide.is-active button').classList.add('focusOutline'); 2325 document.querySelector('.product-banner #updateProductGallery .splide--draggable .splide__slide.is-active button').style.margin = '5px'; 2326 }, 200); 2327 } 2328 // new changes for video component 2329 if (e.target.classList.contains('click-video')) { 2330 if (e.target.closest('.card-video')) { 2331 setTimeout(() => { 2332 if (e.target.closest('.card-video') && e.target.closest('.card-video').querySelector('.wd-modal .wd-modal-close')) { 2333 e.target.closest('.card-video').querySelector('.wd-modal .wd-modal-close').focus(); 2334 } 2335 2336 }, 200); 2337 2338 } 2339 } 2340 if (e.target.classList.contains('videoAnchorOverlayCTA')) { 2341 if (e.target.closest('.videoAnchorOverlay')) { 2342 setTimeout(() => { 2343 if (e.target.closest('.videoAnchorOverlay') && e.target.closest('.videoAnchorOverlay').querySelector('.wd-modal .wd-modal-close')) { 2344 e.target.closest('.videoAnchorOverlay').querySelector('.wd-modal .wd-modal-close').focus(); 2345 } 2346 2347 }, 200); 2348 2349 } 2350 } 2351 2352 // end 2353 if (e.target.classList.contains('slide-down')) { 2354 var clickEvent = new Event('click'); 2355 e.target.dispatchEvent(clickEvent); 2356 var parent = e.target.closest('.pts-accordion-btn'); 2357 if (parent.querySelector('.slide-up')) { 2358 parent.querySelector('.slide-up').focus(); 2359 } 2360 } 2361 if (e.target.classList.contains('slide-up')) { 2362 var clickEvent = new Event('click'); 2363 e.target.dispatchEvent(clickEvent); 2364 var parent = e.target.closest('.pts-accordion-btn'); 2365 if (parent.querySelector('.slide-down')) { 2366 parent.querySelector('.slide-down').focus(); 2367 } 2368 } 2369 if (e.target.classList.contains('mob-openLoginFlyout')) { 2370 e.target.click(); 2371 } 2372 if (e.target.classList.contains('filter-more') || e.target.classList.contains('filter-less')) { 2373 e.target.click(); 2374 } 2375 if (e.target.closest('.clp-pagination-wrap')) { 2376 if (!e.target.classList.contains('pointer-events-none') && !e.target.classList.contains('btnprev') && !e.target.classList.contains('btnnext')) { 2377 e.target.click(); 2378 } 2379 } 2380 if (e.target.tagName === 'A' || e.target.tagName === 'BUTTON') { 2381 if (e.target.classList.contains('compare-link-clp')) { //assigning focus to compare button link 2382 anchorButtonToFocus = e.target; 2383 } 2384 var href = e.target.getAttribute('href'); 2385 if (href && href.substring(1) == 'compare-tray-alert') { 2386 anchorButtonToFocus = e.target; 2387 if (e.keyCode === 32) { 2388 e.target.click(); 2389 } 2390 } 2391 if (href && href.startsWith('#')) { 2392 var modalId = href.substring(1); 2393 var modalContainer = document.querySelector(`#${modalId}`); 2394 if (modalContainer) { 2395 var closeButton = modalContainer.querySelector('.wd-modal-close'); 2396 if (closeButton) { 2397 closeButton.addEventListener('keydown', function (event) { 2398 if (modalId === 'compare-tray-modal' && ((event.keyCode === 13 || event.keyCode === 32) && !event.keyCode === 9)) { 2399 event.stopPropagation(); 2400 event.preventDefault(); 2401 modalContainer.classList.add('hidden'); 2402 if (anchorButtonToFocus) { 2403 anchorButtonToFocus.focus(); 2404 } 2405 } 2406 else { 2407 if ((event.keyCode === 13 || event.keyCode === 32) && !event.keyCode === 9) { 2408 event.stopPropagation(); 2409 event.preventDefault(); 2410 modalContainer.classList.add('hidden'); 2411 anchorButtonToFocus.focus(); 2412 } 2413 } 2414 }); 2415 } 2416 if (modalId === 'compare-tray-modal') { 2417 var observer = new MutationObserver(function (mutations) { 2418 mutations.forEach(function (mutation) { 2419 if (mutation.type === 'attributes' && mutation.attributeName === 'class') { 2420 if (!modalContainer.classList.contains('hidden')) { 2421 closeButton.focus(); 2422 } 2423 } 2424 }); 2425 }); 2426 2427 var config = { attributes: true, attributeFilter: ['class'] }; 2428 observer.observe(modalContainer, config); 2429 if (e.keyCode === 32 && e.target.classList.contains('compare-link-clp')) { 2430 e.target.click(); 2431 if (closeButton) { 2432 closeButton.focus(); 2433 } 2434 } 2435 } else { 2436 closeButton.focus(); 2437 } 2438 } 2439 } 2440 if (e.target.closest(".variant-category-container")) { 2441 e.target.click() 2442 } 2443 if (e.keyCode === 32 && e.target.classList.contains('wd-modal-close')) { 2444 e.target.click(); 2445 if (anchorButtonToFocus) { 2446 anchorButtonToFocus.focus() 2447 } 2448 } 2449 // when press enter or space in add to cart bundle promotion 2450 var currentBundleButton = null; 2451 if (e.target && e.target.closest('.bundlePromotionApp')) { 2452 currentBundleButton = e.target; 2453 var miniCart = document.querySelector('#openCartModal'); 2454 var miniCartCloseBtn = null; 2455 if (miniCart) { 2456 miniCartCloseBtn = miniCart.querySelector('.wd-modal-close'); 2457 } 2458 if (miniCartCloseBtn) { 2459 miniCartCloseBtn.focus(); 2460 // when press enter or space on minicart and add to cart promotion bundle is the page 2461 miniCartCloseBtn.addEventListener('keydown', (event) => { 2462 if (event.keyCode === 13 || event.keyCode === 32) { 2463 event.preventDefault(); 2464 event.stopPropagation(); 2465 if (currentBundleButton.closest('.editorial-dropdown-content-wrap') && currentBundleButton.closest('.editorial-dropdown-content-wrap').previousElementSibling) { 2466 currentBundleButton.closest('.editorial-dropdown-content-wrap').previousElementSibling.focus(); 2467 document.querySelector('body').classList.remove('overflow-hidden'); 2468 } 2469 2470 } 2471 }) 2472 } 2473 2474 } 2475 } 2476 setTimeout(() => { 2477 if (document.querySelector('#compare-tray-alert') && !document.querySelector('#compare-tray-alert').classList.contains('hidden')) { 2478 if (document.querySelector('#compare-tray-alert').querySelector('.alert-close-btn')) { 2479 document.querySelector('#compare-tray-alert').querySelector('.alert-close-btn').focus(); 2480 } 2481 } 2482 }, 300); 2483 // to trigger support chat 2484 if (e.target.classList.contains('js-trigger-start-chat')) { 2485 e.target.click(); 2486 } 2487 if (e.target.classList.contains('addToCartBtn')) { 2488 setTimeout(function () { 2489 document.querySelector('body').classList.remove('disabledOutine'); 2490 document.querySelector('#openCartModal .wd-modal-close').focus(); 2491 }, 800); 2492 } 2493 // tootlTip triger 2494 if (e.target.classList.contains('tooltiptrigger')) { 2495 console.log('clicked on toolTip'); 2496 if (e.target && e.target.querySelector('.tooltipbox')) { 2497 e.target.querySelector('.tooltipbox').style.display = 'block'; 2498 } 2499 } 2500 // for request a quote 2501 if (e.target.classList.contains('wtbBtbwWithIcon') && e.target.getAttribute('data-target') === 'requestQuote-modal') { 2502 e.target.click(); 2503 } 2504 } 2505 var ModalToFocus = ''; 2506 var ModalToFocusCloseBtn = ''; 2507 var compareCloseBtn = ''; 2508 if (document.querySelector('#compare-tray-alert')) { 2509 var ModalToFocus = document.querySelector('#compare-tray-alert'); 2510 var ModalToFocusCloseBtn = ModalToFocus.querySelectorAll('.wd-modal-close'); 2511 var compareCloseBtn = document.querySelectorAll('#compare-tray-modal .wd-modal-close'); 2512 if (ModalToFocusCloseBtn.length > 0) {
2513 ModalToFocusCloseBtn.forEach(function (eachElm) { 2514 eachElm.addEventListener('keydown', function (e) { 2515 if (e.key === "Enter" && PCTFocusBtn) { 2516 e.preventDefault() 2517 e.stopImmediatePropagation(); 2518 e.target.click(); 2519 PCTFocusBtn.focus(); 2520 } 2521 }); 2522 }) 2523 } 2524 if (compareCloseBtn.length > 0) { 2525 compareCloseBtn.forEach(function (eachElm) { 2526 eachElm.addEventListener('keydown', function (e) { 2527 if (e.key === "Enter" && PCTFocusBtn) { 2528 e.preventDefault() 2529 e.stopImmediatePropagation(); 2530 e.target.click(); 2531 PCTFocusBtn.focus(); 2532 } 2533 }); 2534 }) 2535 } 2536 } 2537 2538 // FOR MOBILE 2-5 HEADER 2539 if ((window.innerWidth <= 991)) { 2540 if (document.querySelectorAll('.placeHolder').length > 0) { 2541 document.querySelectorAll('.placeHolder').forEach(function (elm) { 2542 elm.setAttribute('tabindex', 0); 2543 }); 2544 } 2545 if (document.querySelectorAll('.dropDownContainer').length > 0 && document.querySelectorAll('.dropDownContainer .left-slide').length > 0) { 2546 document.querySelectorAll('.dropDownContainer').forEach(function (elm) { 2547 if (elm.classList.contains('hidden')) { 2548 elm.querySelectorAll('.left-slide').forEach(function (innerElm) { 2549 innerElm.setAttribute('tabindex', -1); 2550 }); 2551 } else { 2552 elm.querySelectorAll('.left-slide').forEach(function (innerElm) { 2553 innerElm.setAttribute('tabindex', 0); 2554 }); 2555 } 2556 }); 2557 } 2558 } 2559 // end of movile 2-5 accessibility 2560} 2561// end of movile 2-5 accessibility 2562function checkIfModalHasForm(modalId) { 2563 if (modalId) { 2564 modalId = (modalId.indexOf('#') > -1) ? modalId.replace('#', '') : modalId; 2565 2566 var modalEle = document.getElementById(modalId); 2567 var formElement = modalEle.getElementsByClassName('store-form'); 2568 // if modal has form then only load recaptcha script 2569 if (formElement.length > 0 && !recaptchaScriptLoaded) { 2570 loadRecaptchaScript(); 2571 } 2572 } 2573} 2574//SO Custom Select 2575document.addEventListener('click', function (event) { 2576 let element = event.target.closest('.selectDropdown > li'); 2577 if (element != null && typeof element != 'undefined') { 2578 let elementHTML = element.innerHTML; 2579 element.closest('.dropdownSelectOption').querySelector('.selectedOption').innerHTML = elementHTML; 2580 let selectDropDown = element.closest('.dropdownSelectOption').querySelector('.selectDropdown'); 2581 if (selectDropDown != null && typeof selectDropDown != 'undefined') { 2582 selectDropDown.classList.toggle('hidden'); 2583 selectDropDown.querySelectorAll('li').forEach((selectElement) => { 2584 selectElement.classList.toggle('selected'); 2585 }); 2586 } 2587 } 2588}); 2589 2590document.addEventListener('click', function (event) { 2591 let target = event.target.closest('.optionToggle'); 2592 if (target != null && typeof target != 'undefined') { 2593 let closestDropdown = target.closest('.dropdownSelectOption'); 2594 let selectDropdown = closestDropdown.querySelector('.selectDropdown'); 2595 selectDropdown.classList.toggle('hidden'); 2596 } 2597}); 2598 2599 2600// click event on window 2601window.addEventListener('click', function (e) { 2602 if (e.target.closest('.dropdownSelectOption') == null && document.querySelector('.dropdownSelectOption') != null) { 2603 document.querySelector('.dropdownSelectOption').querySelector('.selectDropdown').classList.add('hidden'); 2604 } 2605 if (e.target.closest('.user-profile') == null && document.querySelector('.user-profile-dropdown') != null) { 2606 document.querySelector('.user-profile-dropdown').removeAttribute('style'); 2607 } 2608 if (!document.querySelector('#predictiveSearchNavForm') && e.target.closest("#searchSummaryViewForm") == null && document.querySelector('.search-expanded') != null) { 2609 var clickEvent = new Event('click'); 2610 document.querySelector(".search-collapse").dispatchEvent(clickEvent); 2611 } 2612}); 2613 2614/* Click function to close the model and stop video*/ 2615window.addEventListener('click', (e) => { 2616 if (e.target.closest('.modal') != null && (e.target.classList.contains('wd-modal-close'))) { 2617 e.target.closest('.wd-modal').classList.add('hidden'); 2618 } 2619 if (e.target.closest('.wd-modal') != null && (e.target.classList.contains('wd-modal-close'))) { 2620 e.target.closest('.wd-modal').classList.add('hidden'); 2621 } 2622 if (e.target.closest('.modal-content') != null && e.target.closest('.modal-content').querySelector('iframe') != null) { 2623 e.target.closest('.modal-content').querySelector('iframe').setAttribute('src', ''); 2624 } 2625}); 2626 2627function storeOpenVideoModal(element) { 2628 let modalId = element.getAttribute('data-target'); 2629 let modalElement = document.getElementById(modalId); 2630 if (typeof (modalElement) != 'undefined') { 2631 modalElement.querySelector('iframe').setAttribute('src', element.getAttribute('data-videosrc')); 2632 body.classList.add('overflow-hidden'); 2633 modalElement.classList.remove('hidden'); 2634 2635 //analytics event dispatch for store 2636 var dataObj = {}; 2637 dataObj.modalId = modalId; 2638 dataObj.videoURL = element.getAttribute('data-videosrc'); 2639 try { 2640 var event = window.aa.createEvent("VIDEO", dataObj); 2641 window.dispatchEvent(event); 2642 } catch (e) { 2643 console.log("Error while triggering analytics VIDEO event"); 2644 } 2645 } 2646} 2647 2648function storeCloseVideoModal(element) { 2649 if (element.closest('.wd-modal') != null && element.closest('.wd-modal').querySelector('iframe') != null) { 2650 element.closest('.wd-modal').classList.add('hidden'); 2651 element.closest('.wd-modal').querySelector('iframe').setAttribute('src', ''); 2652 body.classList.remove('overflow-hidden'); 2653 } 2654} 2655 2656/*add class if view type is section background video (video comp.)*/ 2657if (document.querySelector('.sbgv-main')) { 2658 document.querySelector('.sbgv-main').closest('.video').classList.add('section-bg-video-view'); 2659} 2660 2661/*-- add Play/Pause button for section background video --*/ 2662if (document.querySelector('.pausePlay-btn')) { 2663 document.querySelectorAll(".pausePlay-btn").forEach((thisElement) => { 2664 if (thisElement) { 2665 thisElement.addEventListener('click', function () { 2666 thisElement.classList.toggle('sbgv-is-active'); 2667 if (thisElement.closest('.sbgv-video-contain') && thisElement.closest('.sbgv-video-contain').querySelector('.sbgv-video')) { 2668 var vidState = thisElement.closest('.sbgv-video-contain').querySelector('.sbgv-video'); 2669 if (vidState && thisElement.classList.contains('sbgv-is-active')) { 2670 vidState.play(); 2671 } else { 2672 if (vidState) { 2673 vidState.pause(); 2674 } 2675 } 2676 } 2677 }); 2678 } 2679 }); 2680} 2681 2682// new video banner component 2683document.querySelectorAll('.view-sbgv-main').forEach((component) => { 2684 const videoElements = component.querySelectorAll('.view-sbgv-video'); 2685 const playPauseButton = component.querySelector('.sbgv-pausePlay-btn'); 2686 const audioToggleButton = component.querySelector('.audioToggle-btn'); 2687 2688 // Function to get the currently visible video element 2689 const getVisibleVideoElement = () => { 2690 let visibleVideo = null;
2691 videoElements.forEach((video) => { 2692 const isVisible = 2693 video.offsetWidth > 0 && 2694 video.offsetHeight > 0 && 2695 window.getComputedStyle(video).visibility !== 'hidden'; 2696 if (isVisible) { 2697 visibleVideo = video; 2698 } 2699 }); 2700 return visibleVideo; 2701 }; 2702 2703 // Play/Pause Button Functionality 2704 if (playPauseButton) { 2705 playPauseButton.addEventListener('click', function () { 2706 const videoElement = getVisibleVideoElement(); 2707 if (videoElement) { 2708 if (videoElement.paused) { 2709 let playPromise = videoElement.play(); 2710 if (playPromise !== undefined) { 2711 playPromise.catch((error) => { 2712 console.log('Play prevented:', error); 2713 }); 2714 } 2715 } else { 2716 videoElement.pause(); 2717 } 2718 } 2719 }); 2720 } 2721 2722 // Audio Toggle Button Functionality 2723 if (audioToggleButton) { 2724 const videoElementForAudio = component.querySelector('.view-sbgv-video'); 2725 if (videoElementForAudio) { 2726 const audioEnabled = 2727 videoElementForAudio.getAttribute('data-audio-enabled') === 'true'; 2728 if (audioEnabled) { 2729 audioToggleButton.style.display = 'inline-block'; 2730 2731 // Initialize button state based on video mute state 2732 const initialVideoElement = getVisibleVideoElement(); 2733 if (initialVideoElement) { 2734 if (initialVideoElement.muted) { 2735 audioToggleButton.classList.add('audio-is-active'); 2736 } else { 2737 audioToggleButton.classList.remove('audio-is-active'); 2738 } 2739 } 2740 2741 audioToggleButton.addEventListener('click', function () { 2742 const videoElement = getVisibleVideoElement(); 2743 if (videoElement) { 2744 videoElement.muted = !videoElement.muted; 2745 audioToggleButton.classList.toggle('audio-is-active', videoElement.muted); 2746 } 2747 }); 2748 } else { 2749 audioToggleButton.style.display = 'none'; 2750 videoElements.forEach((videoElement) => { 2751 videoElement.muted = true; 2752 }); 2753 } 2754 } else { 2755 // No video element found for audio toggle 2756 audioToggleButton.style.display = 'none'; 2757 console.warn('No video element found for audio toggle in component:', component); 2758 } 2759 } 2760 2761 // Autoplay on Scroll with Individual Settings 2762 videoElements.forEach((videoElement) => { 2763 const autoplayEnabled = videoElement.getAttribute('data-autoplay-enabled') === 'true'; 2764 const playWhenVisible = videoElement.getAttribute('data-play-when-visible') === 'true'; 2765 const loopCount = parseInt(videoElement.getAttribute('data-loop-count')) || 1; 2766 let playCount = 0; 2767 2768 if (playWhenVisible) { 2769 // Only observe visibility if playWhenVisible is true 2770 const observer = new IntersectionObserver( 2771 (entries) => { 2772 entries.forEach((entry) => { 2773 if (entry.isIntersecting) { 2774 if (videoElement.paused) { 2775 let playPromise = videoElement.play(); 2776 if (playPromise !== undefined) { 2777 playPromise.catch((error) => { 2778 console.log('Autoplay prevented:', error); 2779 }); 2780 } 2781 } 2782 } else { 2783 if (!videoElement.paused) { 2784 videoElement.pause(); 2785 } 2786 } 2787 }); 2788 }, 2789 { threshold: 0.8 } 2790 ); 2791 observer.observe(videoElement); 2792 } else { 2793 // If playWhenVisible is false, ensure the video plays (if not already playing) 2794 if (videoElement.paused) {
2795 let playPromise = videoElement.play(); 2796 if (playPromise !== undefined) { 2797 playPromise.catch((error) => { 2798 console.log('Play prevented:', error); 2799 }); 2800 } 2801 } 2802 } 2803 2804 videoElement.addEventListener('ended', () => { 2805 playCount++; 2806 if (autoplayEnabled && playCount < loopCount) { 2807 videoElement.currentTime = 0; 2808 let playPromise = videoElement.play(); 2809 if (playPromise !== undefined) { 2810 playPromise.catch((error) => { 2811 console.log('Autoplay prevented:', error); 2812 }); 2813 } 2814 } else { 2815 videoElement.pause(); 2816 } 2817 }); 2818 2819 // Update play/pause button state when video plays 2820 videoElement.addEventListener('play', () => { 2821 if (playPauseButton) { 2822 playPauseButton.classList.add('sbgv-is-active'); 2823 } 2824 }); 2825 2826 // Update play/pause button state when video pauses 2827 videoElement.addEventListener('pause', () => { 2828 if (playPauseButton) { 2829 playPauseButton.classList.remove('sbgv-is-active'); 2830 } 2831 }); 2832 }); 2833}); 2834// end of new banner componet 2835 2836 2837//common excelToJson function 2838function getJsonFrmExcelSheet(excelPath, sheetName) { 2839 let servletUrl = ""; 2840 //form servletUrl if sheetName is authored or not 2841 if (sheetName) { 2842 servletUrl = excelPath + ".exceltojson." + sheetName + ".json"; 2843 } else { 2844 servletUrl = excelPath + ".exceltojson.json"; 2845 } 2846 // call ExcelToJsonServlet and return the json of the excel data 2847 return fetch(servletUrl); 2848} 2849 2850//get the next element by selector 2851function next(elem, selector) { 2852 2853 // Get the next element 2854 var nextElem = elem.nextElementSibling; 2855 2856 // If there's no selector, return the next element 2857 if (!selector) { 2858 return nextElem; 2859 } 2860 2861 // Otherwise, check if the element matches the selector 2862 if (nextElem && nextElem.matches(selector)) { 2863 return nextElem; 2864 } 2865 2866 // if it's not a match, return null 2867 return null; 2868 2869}; 2870 2871// Utility for select drop down href redirect 2872document.addEventListener('DOMContentLoaded', function () { 2873 if (document.getElementsByClassName("clickableDropdown")[0]) { 2874 document.getElementsByClassName("clickableDropdown")[0].addEventListener('change', function (e) { 2875 let url = e.srcElement.value; 2876 if (url) { 2877 window.location.href = url; 2878 } 2879 return false; 2880 }); 2881 } 2882 // selecting the country based on locale. 2883 2884 function onCountryDropdownOptionsLoaded(formId) { 2885 var form = document.getElementById(formId); 2886 if (!form) { 2887 console.log("Form not found!"); 2888 return; 2889 } 2890 var sel = form.querySelector('select[name="country"]'); 2891 if (!sel) { 2892 console.log("Country dropdown not found!"); 2893 return; 2894 } 2895 2896 function watchOptions(selectElem) { 2897 if (!selectElem) return; 2898 function printAllOptions(sel) { 2899 var countryCodeMap = { 2900 'AL': 'Albania','DZ': 'Algeria','AG': 'Antigua and Barbuda','AR': 'Argentina', 2901 'AU': 'Australia','AT': 'Austria','BH': 'Bahrain','BY': 'Belarus','BE': 'Belgium', 2902 'BO': 'Bolivia','BA': 'Bosnia Herzegovina','BW': 'Botswana','BR': 'Brazil', 2903 'BG': 'Bulgaria','CA': 'Canada','CL': 'Chile','CN': 'China','CO': 'Colombia', 2904 'CR': 'Costa Rica','HR': 'Croatia','CY': 'Cyprus','CZ': 'Czech Republic', 2905 'DK': 'Denmark','DO': 'Dominican Republic','EC': 'Ecuador','EG': 'Egypt', 2906 'SV': 'El Salvador','EE': 'Estonia','FI': 'Finland','FR': 'France', 2907 'DE': 'Germany','GH': 'Ghana','GR': 'Greece','GT': 'Guatemala','HN': 'Honduras', 2908 'HK': 'Hong Kong (China)','HU': 'Hungary','IS': 'Iceland','IN': 'India', 2909 'ID': 'Indonesia','IE': 'Ireland','IL': 'Israel','IT': 'Italy','JP': 'Japan', 2910 'JO': 'Jordan','KE': 'Kenya','KR': 'Korea','KW': 'Kuwait','LV': 'Latvia', 2911 'LB': 'Lebanon','LT': 'Lithuania','LU': 'Luxembourg','MK': 'Macedonia', 2912 'MY': 'Malaysia','MT': 'Malta','MX': 'Mexico','MA': 'Morocco','MZ': 'Mozambique',
2913 'NA': 'Namibia','NL': 'Netherlands','NZ': 'New Zealand','NI': 'Nicaragua', 2914 'NG': 'Nigeria','NO': 'Norway','OM': 'Oman','PA': 'Panama','PY': 'Paraguay', 2915 'PE': 'Peru','PH': 'Philippines','PL': 'Poland','PT': 'Portugal','PR': 'Puerto Rico', 2916 'QA': 'Qatar','RO': 'Romania','RU': 'Russia','SA': 'Saudi Arabia','RS': 'Serbia', 2917 'SG': 'Singapore','SK': 'Slovakia','SI': 'Slovenia','ZA': 'South Africa', 2918 'ES': 'Spain','SE': 'Sweden','CH': 'Switzerland','TW': 'Taiwan','TH': 'Thailand', 2919 'TN': 'Tunsia','TR': 'Turkey','UG': 'Uganda','UA': 'Ukraine','AE': 'United Arab Emirates', 2920 'GB': 'United Kingdom','US': 'United States','UY': 'Uruguay','VE': 'Venezuela', 2921 'VN': 'Vietnam','YE': 'Yemen','ZM': 'Zambia','ZW': 'Zimbabwe' 2922 }; 2923 2924 var i; 2925 for (i = 0; i < sel.options.length; i++) { 2926 var opt = sel.options[i]; 2927 // console.log('<option value="' + opt.value + '">' + opt.text + '</option>'); 2928 } 2929 var meta = document.querySelector('meta[property="og:locale"]'); 2930 var locale = null; 2931 if (meta) { 2932 locale = meta.getAttribute('content'); 2933 } 2934 var code = null; 2935 if (locale && locale.split('_').length === 2) { 2936 code = locale.split('_')[1]; 2937 if (code) code = code.toUpperCase(); 2938 } 2939 var country = null; 2940 if (code && countryCodeMap[code]) { 2941 country = countryCodeMap[code]; 2942 } 2943 if (country) { 2944 var found = null; 2945 for (i = 0; i < sel.options.length; i++) { 2946 var val = sel.options[i].value; 2947 var txt = sel.options[i].text; 2948 if ( 2949 val.replace(/^\s+|\s+$/g, '') === country || 2950 txt.replace(/^\s+|\s+$/g, '') === country || 2951 val.replace(/^\s+|\s+$/g, '') === code 2952 ) { 2953 found = sel.options[i]; 2954 break; 2955 } 2956 } 2957 if (found) { 2958 console.log('Matched country for locale:', country); 2959 setTimeout(function() { 2960 sel.value = country; 2961 }, 1000); 2962 } else { 2963 console.log('No matching country in dropdown for locale:', country); 2964 } 2965 } else { 2966 console.log('No country match for locale'); 2967 } 2968 } 2969 2970 var optionObserver = new MutationObserver(function() { 2971 if (selectElem.options.length > 1) { 2972 console.log('Country dropdown options loaded (observer).'); 2973 printAllOptions(selectElem); 2974 optionObserver.disconnect(); 2975 } 2976 }); 2977 optionObserver.observe(selectElem, { childList: true }); 2978 if (selectElem.options.length > 1) { 2979 console.log('Country dropdown options are loaded (initial check).'); 2980 printAllOptions(selectElem); 2981 optionObserver.disconnect(); 2982 } 2983 } 2984 2985 var parent = sel.parentNode; 2986 var selectObserver = new MutationObserver(function() { 2987 var sel2 = form.querySelector('select[name="country"]'); 2988 if (sel2 && sel2 !== sel) { 2989 sel = sel2; 2990 watchOptions(sel2); 2991 } 2992 }); 2993 selectObserver.observe(parent, { childList: true, subtree: false }); 2994 watchOptions(sel); 2995 } 2996 2997 onCountryDropdownOptionsLoaded('webform-looking-to-purchase-form'); 2998 2999 // end 3000 3001 // autofill D&B state only for US 3002 const usStateMap = { 3003 'AL': 'Alabama', 'AK': 'Alaska', 'AZ': 'Arizona', 'AR': 'Arkansas', 3004 'CA': 'California', 'CO': 'Colorado', 'CT': 'Connecticut', 'DE': 'Delaware', 3005 'FL': 'Florida', 'GA': 'Georgia', 'HI': 'Hawaii', 'ID': 'Idaho', 3006 'IL': 'Illinois', 'IN': 'Indiana', 'IA': 'Iowa', 'KS': 'Kansas', 3007 'KY': 'Kentucky', 'LA': 'Louisiana', 'ME': 'Maine', 'MD': 'Maryland', 3008 'MA': 'Massachusetts', 'MI': 'Michigan', 'MN': 'Minnesota', 'MS': 'Mississippi',
3009 'MO': 'Missouri', 'MT': 'Montana', 'NE': 'Nebraska', 'NV': 'Nevada', 3010 'NH': 'New Hampshire', 'NJ': 'New Jersey', 'NM': 'New Mexico', 'NY': 'New York', 3011 'NC': 'North Carolina', 'ND': 'North Dakota', 'OH': 'Ohio', 'OK': 'Oklahoma', 3012 'OR': 'Oregon', 'PA': 'Pennsylvania', 'RI': 'Rhode Island', 'SC': 'South Carolina', 3013 'SD': 'South Dakota', 'TN': 'Tennessee', 'TX': 'Texas', 'UT': 'Utah', 3014 'VT': 'Vermont', 'VA': 'Virginia', 'WA': 'Washington', 'WV': 'West Virginia', 3015 'WI': 'Wisconsin', 'WY': 'Wyoming', 3016 'DC': 'District of Columbia' 3017 }; 3018 3019 function observeUSStateField(formEl) { 3020 if (!formEl) return; 3021 const countrySelect = formEl.querySelector('select[name="country"]'); 3022 const stateInput = formEl.querySelector('input[name="state"]'); 3023 if (!countrySelect || !stateInput) return; 3024 let lastValue = stateInput.value; 3025 const observer = new MutationObserver(() => { 3026 let newValue = stateInput.value.trim(); 3027 if (newValue !== lastValue) { 3028 lastValue = newValue; 3029 tryConvert(); 3030 } 3031 }); 3032 3033 observer.observe(stateInput, { attributes: true, attributeFilter: ['value'] }); 3034 stateInput.addEventListener('input', tryConvert); 3035 3036 function tryConvert() { 3037 const countryVal = countrySelect.value.trim(); 3038 const shortCode = stateInput.value.trim().toUpperCase(); 3039 if (countryVal === 'United States' && usStateMap[shortCode]) { 3040 stateInput.value = usStateMap[shortCode]; 3041 stateInput.dispatchEvent(new Event('input', { bubbles: true })); 3042 stateInput.dispatchEvent(new Event('change', { bubbles: true })); 3043 } 3044 } 3045 } 3046 observeUSStateField(document.getElementById('webform-looking-to-purchase-form')); 3047 3048 //end 3049}); 3050 3051// Parallax animation 3052document.addEventListener('DOMContentLoaded', function () { 3053 if (document.querySelector('.wd-rellax')) { 3054 var elements = document.querySelectorAll('.wd-rellax'); 3055 elements.forEach(function (element) { 3056 var rellax = new Rellax(element, { 3057 speed: 2 3058 }); 3059 }); 3060 } 3061 if (document.querySelector('.wd-rellax-slow')) { 3062 var elements = document.querySelectorAll('.wd-rellax-slow'); 3063 elements.forEach(function (element) { 3064 var rellax = new Rellax(element, { 3065 speed: 1.32 3066 }); 3067 }); 3068 } 3069 if (document.querySelector('.wd-rellax-fast')) { 3070 var elements = document.querySelectorAll('.wd-rellax-fast'); 3071 elements.forEach(function (element) { 3072 var rellax = new Rellax(element, { 3073 speed: 2.66 3074 }); 3075 }); 3076 } 3077}); 3078// Product Card ADA - Add tabindex="-1" to parent if CTA button exists 3079document.addEventListener('DOMContentLoaded', () => { 3080 function addTabindexToParents() { 3081 // Loop through all product cards 3082 document.querySelectorAll('.product-card').forEach(card => { 3083 // Find button inside each card 3084 const ctaBtn = card.querySelector('.pc-cta-btn'); 3085 if (ctaBtn) { 3086 // Find its closest parent with either of the two classes 3087 const parent = ctaBtn.closest('.pc-url-wrap, .pc-quickView-wrap'); 3088 if (parent && !parent.hasAttribute('tabindex')) { 3089 parent.setAttribute('tabindex', '-1'); 3090 } 3091 } 3092 }); 3093 } 3094 3095 // Initial run (after slight delay for slow-loading DOMs) 3096 setTimeout(addTabindexToParents, 500); 3097 3098 // Watch for dynamically added product cards (optional but safe) 3099 const observer = new MutationObserver(() => addTabindexToParents()); 3100 observer.observe(document.body, { childList: true, subtree: true }); 3101}); 3102 3103document.addEventListener("DOMContentLoaded", () => { 3104 const link = document.getElementById("print-pdf"); 3105 if (!link) return; 3106 3107 const iframe = document.getElementById("print-frame"); 3108 if (!iframe) return; 3109 3110 link.addEventListener("click", async (e) => { 3111 e.preventDefault(); 3112 3113 try { 3114 const response = await fetch(link.href); 3115 if (!response.ok) return; 3116 3117 const blob = await response.blob(); 3118 const blobUrl = URL.createObjectURL(blob); 3119 3120 iframe.onload = () => { 3121 iframe.contentWindow?.focus(); 3122 iframe.contentWindow?.print(); 3123 setTimeout(() => URL.revokeObjectURL(blobUrl), 1000); 3124 }; 3125 3126 iframe.src = blobUrl; 3127 } catch (err) { 3128 console.error(err); 3129 } 3130 }); 3131}); 3132//Ixpand mobile header 3133$(document).ready(function() { 3134 $('.ixpand-hamburger').on('click', function () { 3135 $('body').toggleClass('preventScroll'); 3136 }); 3137 3138 $('iframe').each(function() { 3139 var iframe = $(this); 3140 if(!iframe.hasClass('noresize')) { 3141 iframe.iFrameResize({ 3142 log: false, // Enable console logging 3143 enablePublicMethods: false 3144 }); 3145 } 3146 }); 3147}); 3148 3149/* Carousel Component JS */ 3150document.addEventListener('DOMContentLoaded', function () { 3151 3152 var heroBannerCarouselElements = document.querySelectorAll(".heroBannerCarousel"); 3153 3154 if (heroBannerCarouselElements.length > 0) { 3155 3156 3157 if (document.querySelector('.promo-carousel') != null) { 3158 document.querySelectorAll(".heroBannerCarousel.slider.promo-carousel").forEach((thisElement) => { 3159 3160 if (hasClass(thisElement, 'slider') && hasClass(thisElement, 'promo-carousel')) { 3161 3162 thisElement.querySelectorAll('.slide').forEach((slideElement, idx) => { 3163 3164 thisElement.closest('section').querySelector('.heroBannerCarousel.splide.promo-carousel .splide__list').children[idx].innerHTML = slideElement.innerHTML; 3165 }) 3166 3167 //thisElement.remove(); 3168 3169 } 3170 3171 }) 3172 } 3173 3174 var elements = document.querySelectorAll('.heroBannerCarousel .reference'); 3175 if (elements.length > 0) {
3176 elements.forEach((eachReference) => { 3177 if (eachReference.parentNode.children.length == 1 && eachReference.children.length == 0) { 3178 if (eachReference.closest('.splide__slide')) { 3179 eachReference.closest('.splide__slide').remove(); 3180 } 3181 } 3182 }) 3183 } 3184 3185 document.querySelectorAll(".heroBannerCarousel.splide").forEach((thisElement) => { 3186 3187 if (hasClass(thisElement, 'splide')) { 3188 3189 try { 3190 let autoPlay = thisElement.getAttribute("data-autorotate"); 3191 let autoPlaySpeed = thisElement.getAttribute("data-autorotatespeed"); 3192 let pauseOnHover = thisElement.getAttribute("data-pauseonhover"); 3193 3194 if (hasClass(thisElement, 'promo-carousel')) { 3195 let promo = new Splide(thisElement, { 3196 preloadPages: 1, 3197 perPage: 1, 3198 type: 'fade', 3199 height: '40px', 3200 pagination: false, 3201 arrows: true, 3202 cover: true, 3203 autoplay: true, 3204 interval: 7000, 3205 wheel: false, 3206 rewind: true, 3207 dragMinThreshold: 1 3208 3209 }); 3210 promo.mount(); 3211 } else if (hasClass(thisElement, 'wd-card-carousel')) { 3212 var splideListCount = thisElement.querySelector('ul.splide__list').childElementCount 3213 let card = new Splide(thisElement, { 3214 lazyLoad: 'nearby', 3215 preloadPages: 1, 3216 perPage: 1, 3217 //drag : 'free', 3218 //flickPower: 300, 3219 //snap : false, 3220 type: 'scroll', 3221 height: 'auto', 3222 pagination: false, 3223 arrows: splideListCount > 1 ? true : false, 3224 gap: 8, 3225 autoWidth: true, 3226 perMove : 1, 3227 dragMinThreshold: { 3228 mouse: 4, 3229 touch: 10, 3230 }, 3231 breakpoints: { 3232 7680: { 3233 perPage: 3, 3234 arrows: splideListCount > 3 ? true : false, 3235 gap: 16, 3236 }, 3237 1920: { 3238 perPage: 3, 3239 arrows: splideListCount > 3 ? true : false, 3240 gap: 16, 3241 }, 3242 1464: { 3243 perPage: 3, 3244 arrows: splideListCount > 3 ? true : false, 3245 gap: 16, 3246 }, 3247 1024: { 3248 perPage: 2, 3249 arrows: splideListCount > 2 ? true : false, 3250 gap: 16, 3251 }, 3252 992: { 3253 perPage: 2, 3254 arrows: splideListCount > 2 ? true : false, 3255 gap: 16, 3256 }, 3257 768: { 3258 perPage: 1, 3259 arrows: splideListCount > 1 ? true : false, 3260 }, 3261 576: { 3262 perPage: 1, 3263 arrows: splideListCount > 1 ? true : false, 3264 autoWidth: false, 3265 fixedWidth: '80%', 3266 }, 3267 3268 }, 3269 3270 }); 3271 // card.mount(); 3272 card.mount(); 3273 slidNavshow(thisElement); 3274 window.addEventListener('resize', function (event) { 3275 slidNavshow(thisElement); 3276 }, true); 3277 card.on('moved', function () { 3278 slidNavshow(thisElement); 3279 }); 3280 // Enable horizontal wheel scroll on this carousel
3281 enableHorizontalWheelScroll('.wd-card-carousel .splide__track', card, 300); 3282 } else if (hasClass(thisElement, 'wd-hero-carousel')) { 3283 if (document.querySelector("html").getAttribute("dir") === 'rtl') { 3284 wdHeroCarousel('rtl', thisElement); 3285 } else { 3286 wdHeroCarousel('ltr', thisElement); 3287 } 3288 3289 } else if (hasClass(thisElement, 'wd-1col-carousel')) { 3290 var splideListWdLcolCarouselCount = thisElement.querySelector('ul.splide__list').childElementCount; 3291 var shouldAutoplay = splideListWdLcolCarouselCount > 1 && autoPlay === 'true' ; 3292 let oneCol = new Splide(thisElement, { 3293 lazyLoad: 'nearby', 3294 preloadPages: 1, 3295 perPage: 1, 3296 wheel: false, 3297 height: 'auto', 3298 pagination: false, 3299 //arrows : true, 3300 //cover : true, 3301 type: splideListWdLcolCarouselCount > 1 ? 'loop' : '', 3302 autoplay: shouldAutoplay, 3303 interval: autoPlaySpeed ? autoPlaySpeed : 3000, 3304 pauseOnHover: pauseOnHover, 3305 arrows: splideListWdLcolCarouselCount > 1 ? true : false, 3306 gap: 16, 3307 dragMinThreshold: { 3308 mouse: 4, 3309 touch: 10, 3310 }, 3311 3312 }); 3313 oneCol.mount(); 3314 slidNavshow(thisElement); 3315 window.addEventListener('resize', function (event) { 3316 slidNavshow(thisElement); 3317 }, true); 3318 oneCol.on('moved', function () { 3319 slidNavshow(thisElement); 3320 }); 3321 } else if (hasClass(thisElement, 'wd-2col-carousel')) { 3322 var splideListWdLcolCarouse2Count = thisElement.querySelector('ul.splide__list').childElementCount; 3323 var shouldAutoplay = splideListWdLcolCarouse2Count > 1 && autoPlay === 'true' ; 3324 let twoCol = new Splide(thisElement, { 3325 lazyLoad: 'nearby', 3326 preloadPages: 1, 3327 perPage: 2, 3328 wheel: false, 3329 height: 'auto', 3330 pagination: false, 3331 //arrows : true, 3332 //cover : true, 3333 type: splideListWdLcolCarouse2Count > 2 ? 'loop' : '', 3334 autoplay: shouldAutoplay, 3335 interval: autoPlaySpeed ? autoPlaySpeed : 3000, 3336 pauseOnHover: pauseOnHover, 3337 gap: 16, 3338 arrows: splideListWdLcolCarouse2Count > 2 ? true : false, 3339 dragMinThreshold: { 3340 mouse: 4, 3341 touch: 10, 3342 }, 3343 breakpoints: { 3344 3345 992: { 3346 perPage: 2, 3347 arrows: splideListWdLcolCarouse2Count > 2 ? true : false, 3348 gap: 16, 3349 }, 3350 768: { 3351 perPage: 1, 3352 arrows: splideListWdLcolCarouse2Count > 1 ? true : false, 3353 3354 }, 3355 576: { 3356 perPage: 1, 3357 arrows: splideListWdLcolCarouse2Count > 1 ? true : false, 3358 }, 3359 3360 }, 3361 3362 }); 3363 twoCol.mount(); 3364 slidNavshow(thisElement); 3365 window.addEventListener('resize', function (event) { 3366 slidNavshow(thisElement); 3367 }, true); 3368 twoCol.on('moved', function () { 3369 slidNavshow(thisElement); 3370 }); 3371 3372 } else if (hasClass(thisElement, 'wd-4col-carousel')) { 3373 var splideListWdLcolCarouse4Count = thisElement.querySelector('ul.splide__list').childElementCount; 3374 var shouldAutoplay = splideListWdLcolCarouse4Count > 1 && autoPlay === 'true' ; 3375 let fourCol = new Splide(thisElement, { 3376 lazyLoad: 'nearby', 3377 preloadPages: 1, 3378 perPage: 4, 3379 arrows: splideListWdLcolCarouse4Count > 4 ? true : false, 3380 wheel: false, 3381 height: 'auto', 3382 pagination: false, 3383 //arrows : true, 3384 //cover : true, 3385 type: splideListWdLcolCarouse4Count > 4 ? 'loop' : '', 3386 autoplay: shouldAutoplay, 3387 interval: autoPlaySpeed ? autoPlaySpeed : 3000, 3388 pauseOnHover: pauseOnHover, 3389 gap: 16, 3390 dragMinThreshold: { 3391 mouse: 4, 3392 touch: 10, 3393 }, 3394 breakpoints: { 3395 7680: { 3396 perPage: 5, 3397 arrows: splideListWdLcolCarouse4Count > 5 ? true : false, 3398 gap: 16, 3399 }, 3400 1920: { 3401 perPage: 4, 3402 arrows: splideListWdLcolCarouse4Count > 4 ? true : false, 3403 gap: 16, 3404 }, 3405 1464: { 3406 perPage: 3, 3407 arrows: splideListWdLcolCarouse4Count > 3 ? true : false, 3408 gap: 16, 3409 }, 3410 992: { 3411 perPage: 2, 3412 arrows: splideListWdLcolCarouse4Count > 2 ? true : false, 3413 gap: 16, 3414 }, 3415 768: { 3416 perPage: 1, 3417 arrows: splideListWdLcolCarouse4Count > 1 ? true : false, 3418 3419 }, 3420 576: { 3421 perPage: 1, 3422 arrows: splideListWdLcolCarouse4Count > 1 ? true : false, 3423 }, 3424 3425 }, 3426 3427 }); 3428 fourCol.mount(); 3429 slidNavshow(thisElement); 3430 window.addEventListener('resize', function (event) { 3431 slidNavshow(thisElement); 3432 }, true); 3433 fourCol.on('moved', function () { 3434 slidNavshow(thisElement); 3435 }); 3436 } else if (hasClass(thisElement, 'wd-custom-carousel')) { 3437 let custom = new Splide(thisElement, { 3438 preloadPages: 1, 3439 perPage: 1, 3440 //type : 'scroll', 3441 type: 'loop', 3442 height: '40px', 3443 pagination: false, 3444 arrows: true, 3445 cover: true, 3446 autoplay: true 3447 }); 3448 custom.mount(); 3449 } else if (hasClass(thisElement, 'wd-hero-progressBar')) { 3450 var countPB = thisElement.querySelector('ul.splide__list').childElementCount; 3451 var autoPlayPB = thisElement.getAttribute('data-autorotate'); 3452 var autoPlaySpeedPB = thisElement.getAttribute('data-autorotatespeed'); 3453 var pauseOnHoverPB = (function(v){ return /^(true|1|yes|y|on)$/i.test((v || '').trim()); })(thisElement.getAttribute('data-pauseonhover')); 3454 var dirPB = document.querySelector('html').getAttribute('dir') === 'rtl' ? 'rtl' : 'ltr'; 3455 3456 let heroPB = new Splide(thisElement, { 3457 lazyLoad: 'nearby', 3458 preloadPages: 1, 3459 perPage: 1, 3460 wheel: false, 3461 height: 'auto', 3462 pagination: false, 3463 arrows: countPB > 1 ? true : false, 3464 type: countPB > 1 ? 'loop' : '', 3465 autoplay: countPB > 1 ? autoPlayPB : '', 3466 interval: autoPlaySpeedPB ? autoPlaySpeedPB : 3000, 3467 pauseOnHover: pauseOnHoverPB, 3468 dragMinThreshold: { mouse: 4, touch: 10 }, 3469 direction: dirPB 3470 }); 3471 3472 thisElement.splideInstance = heroPB; 3473 bindProgress(thisElement, heroPB); 3474 heroPB.mount(); 3475 } 3476 } catch (e) { 3477 console.log('error while init carousel', e); 3478 } 3479 } 3480 }); 3481 } 3482}); 3483if (document.querySelector('.splide-progressbar') && document.querySelector('.splide-progressbar').closest('.carousel')) { 3484 document.querySelector('.splide-progressbar').closest('.carousel').classList.add('relative'); 3485} 3486function findProgressContainer(sectionEl) { 3487 var n = sectionEl; 3488 while (n && (n = n.nextElementSibling)) { 3489 if (n.classList && n.classList.contains('splide-progressbar')) return n; 3490 } 3491 return null; 3492} 3493function bindProgressTheme(root, inst) { 3494 var section = root.closest('section') || root; 3495 var progress = root.parentElement.querySelector('.splide-progressbar'); 3496 if(!progress) return; 3497 var host = progress.closest('.carousel') || progress; 3498 3499 function apply(){ 3500 var active = root.querySelector('.splide__slide.is-active'); 3501 var hasDark = !!(active && active.querySelector('section.dark-theme')); 3502 if(host) { 3503 host.classList.toggle('text-white', hasDark); 3504 host.classList.toggle('dark-theme-wrap', hasDark); 3505 } 3506 } 3507 3508 apply(); 3509 inst.on('mounted move updated refresh active inactive', apply); 3510 3511 var list = root.querySelector('.splide__list'); 3512 if(list){ 3513 var mo = new MutationObserver(apply); 3514 mo.observe(list, { attributes: true, subtree: true, attributeFilter: ['class'] }); 3515 } 3516} 3517 3518function bindProgress(root, inst){ 3519 var section = root.closest('section') || root; 3520 var progress = root.parentElement.querySelector('.splide-progressbar'); 3521 if(!progress) return; 3522 3523 var slides = root.querySelectorAll('.splide__slide'); 3524 var rawItems = progress.querySelectorAll(':scope > div:not(.wd-bars):not(.wd-details)'); 3525 if(rawItems.length !== slides.length) return; 3526 var barsWrap = progress.querySelector('.wd-bars'); 3527 if(!barsWrap){ 3528 barsWrap = document.createElement('div'); 3529 barsWrap.className = 'wd-bars contain relative mx-auto'; 3530 progress.prepend(barsWrap); 3531 }
3532 progress.style.setProperty('--wd-count', String(slides.length)); 3533 3534 var items = []; 3535 rawItems.forEach(function(el, i){ 3536 el.classList.add('wd-progress-item'); 3537 el.setAttribute('data-index', i); 3538 var t = (el.querySelector('h3') && el.querySelector('h3').textContent) || ''; 3539 var d = (el.querySelector('p') && el.querySelector('p').textContent) || ''; 3540 el.innerHTML = ''; 3541 3542 var track = document.createElement('span'); 3543 track.className = 'wd-progress-track'; 3544 var fill = document.createElement('span'); 3545 fill.className = 'wd-progress-fill'; 3546 track.appendChild(fill); 3547 3548 var label = document.createElement('div'); 3549 label.className = 'wd-item-label'; 3550 var tt = document.createElement('span'); 3551 tt.className = 'wd-item-title'; 3552 tt.textContent = t; 3553 var dd = document.createElement('span'); 3554 dd.className = 'wd-item-desc'; 3555 dd.textContent = d; 3556 label.appendChild(tt); 3557 label.appendChild(dd); 3558 3559 el.appendChild(track); 3560 el.appendChild(label); 3561 3562 el.addEventListener('click', function(){ inst.go(i); }); 3563 el.setAttribute('role','button'); 3564 el.setAttribute('tabindex','0'); 3565 el.addEventListener('keydown', function(e){ if(e.key==='Enter'||e.key===' '){ e.preventDefault(); inst.go(i); }}); 3566 3567 barsWrap.appendChild(el); 3568 items.push({ host: el, fill: fill }); 3569 }); 3570 3571 var active = 0; 3572 function reset(){ items.forEach(function(it){ it.fill.style.width = '0%'; it.host.classList.remove('is-active'); it.host.removeAttribute('aria-current'); }); } 3573 function setActive(i){ reset(); if(items[i]){ items[i].host.classList.add('is-active'); items[i].host.setAttribute('aria-current','true'); } } 3574 3575 inst.on('mounted move', function(i){ active = typeof i==='number' ? i : inst.index; setActive(active); }); 3576 inst.on('autoplay:playing', function(rate){ if(items[active]) items[active].fill.style.width = Math.min(100, Math.max(0, rate*100)) + '%'; }); 3577 bindProgressTheme(root, inst); 3578} 3579 3580function hasClass(target, className) { 3581 return target.classList.contains(className); 3582} 3583function slidNavshow(currentElement) { 3584 if (currentElement.querySelector('.splide__slider .splide__arrows')) { 3585 currentElement.querySelector('.splide__slider ul.splide__list').classList.remove('justify-center'); 3586 // var tags = document.getElementsByClassName("wd-card-carousel")[0]; 3587 if (currentElement.getElementsByClassName('firstSlide')[0].classList.contains("is-visible")) { 3588 currentElement.getElementsByClassName('splide__track')[0].classList.remove('leftSpace'); 3589 currentElement.getElementsByClassName('splide__track')[0].classList.add('rightSpace'); 3590 } else if (currentElement.getElementsByClassName('lastSlide')[0].classList.contains("is-visible")) { 3591 currentElement.getElementsByClassName('splide__track')[0].classList.remove('rightSpace'); 3592 currentElement.getElementsByClassName('splide__track')[0].classList.add('leftSpace'); 3593 } 3594 } else { 3595 currentElement.getElementsByClassName('splide__track')[0].classList.remove('leftSpace'); 3596 currentElement.getElementsByClassName('splide__track')[0].classList.remove('rightSpace'); 3597 currentElement.querySelector('.splide__slider ul.splide__list').classList.add('justify-center'); 3598 } 3599} 3600// check if Subnav component is present on DOM or not. 3601function checkForSubNav(_hero) { 3602 _hero.mount(); 3603 var goToSlideBtn = document.querySelectorAll('.subnav-link-to-carousel a') || ''; 3604 if (goToSlideBtn.length > 0) { 3605 goToSlideBtn.forEach(function (elm) { 3606 elm.addEventListener('click', function (e) { 3607 e.preventDefault(); 3608 e.stopPropagation(); 3609 var slider = elm.closest('.subnav-link-to-carousel').querySelector('.slidingDiv'); 3610 var left = elm.offsetLeft; 3611 var width = elm.offsetWidth; 3612 var href = elm.getAttribute('href'); 3613 if (href.startsWith('#')) { 3614 var togoSlide = parseInt(href.split('-')[href.split('-').length - 1]); 3615 hero.go(togoSlide); 3616 slider.style.cssText = `
3617 left: ${left}px; 3618 width: ${width}px; 3619 `; 3620 } 3621 }); 3622 }); 3623 _hero.on('moved', function (e) { 3624 var activeslide = thisElement.querySelector('.is-active'); 3625 var id = activeslide.querySelector('section').getAttribute('id'); 3626 var slideitem = document.querySelector(`[href="#${id}"]`); 3627 if (slideitem) { 3628 var left = slideitem.offsetLeft; 3629 var width = slideitem.offsetWidth; 3630 var slider = slideitem.closest('.subnav-link-to-carousel').querySelector('.slidingDiv'); 3631 slider.style.cssText = ` 3632 left: ${left}px; 3633 width: ${width}px; 3634 `; 3635 } 3636 3637 }); 3638 } 3639} 3640// to disable to WDhero carousel in mobile view. 3641function splideMobileView(_hero) { 3642 _hero.mount(); 3643 var goToSlideBtn = document.querySelectorAll('.subnav-link-to-carousel a') || ''; 3644 if (goToSlideBtn.length > 0) { 3645 goToSlideBtn.forEach(function (elm) { 3646 elm.addEventListener('click', function () { 3647 e.preventDefault(); 3648 e.stopPropagation(); 3649 var slider = elm.closest('.subnav-link-to-carousel').querySelector('.slidingDiv'); 3650 var left = elm.offsetLeft; 3651 var width = elm.offsetWidth; 3652 var href = elm.getAttribute('href'); 3653 if (href.startsWith('#')) { 3654 var togoSlide = parseInt(href.split('-')[href.split('-').length - 1]); 3655 _hero.go(togoSlide); 3656 slider.style.cssText = ` 3657 left: ${left}px; 3658 width: ${width}px; 3659 `; 3660 } 3661 }); 3662 }); 3663 } 3664} 3665function wdHeroCarousel(dir, thisElement) { 3666 let autoPlay = thisElement.getAttribute("data-autorotate"); 3667 let autoPlaySpeed = thisElement.getAttribute("data-autorotatespeed"); 3668 let pauseOnHover = thisElement.getAttribute("data-pauseonhover"); 3669 3670 if (hasClass(thisElement, 'disable-splide-mobile')) { 3671 if (window.innerWidth >= 991) { 3672 var splideListWdHeroCarouselCount = thisElement.querySelector('ul.splide__list').childElementCount 3673 let hero = new Splide(thisElement, { 3674 lazyLoad: 'nearby', 3675 preloadPages: 1, 3676 perPage: 1, 3677 wheel: false, 3678 height: 'auto', 3679 pagination: splideListWdHeroCarouselCount > 1 ? true : false, 3680 arrows: splideListWdHeroCarouselCount > 1 ? true : false, 3681 //cover : true, 3682 type: splideListWdHeroCarouselCount > 1 ? 'loop' : '', 3683 autoplay: splideListWdHeroCarouselCount > 1 ? autoPlay : '', 3684 interval: autoPlaySpeed ? autoPlaySpeed : 3000, 3685 pauseOnHover: pauseOnHover, 3686 dragMinThreshold: { 3687 mouse: 4, 3688 touch: 10, 3689 }, 3690 direction: dir, 3691 3692 }); 3693 if (document.querySelector('.subnav-link-to-carousel')) { 3694 window.addEventListener('load', (event) => { 3695 this.checkForSubNav(hero); 3696 }); 3697 } else { 3698 this.checkForSubNav(hero); 3699 } 3700 } 3701 } else { 3702 var splideListWdHeroCarouselCount = thisElement.querySelector('ul.splide__list').childElementCount 3703 let hero = new Splide(thisElement, { 3704 lazyLoad: 'nearby', 3705 preloadPages: 1, 3706 perPage: 1, 3707 wheel: false, 3708 height: 'auto', 3709 pagination: splideListWdHeroCarouselCount > 1 ? true : false, 3710 arrows: splideListWdHeroCarouselCount > 1 ? true : false, 3711 //cover : true, 3712 type: splideListWdHeroCarouselCount > 1 ? 'loop' : '', 3713 autoplay: splideListWdHeroCarouselCount > 1 ? autoPlay : '', 3714 interval: autoPlaySpeed ? autoPlaySpeed : 3000, 3715 pauseOnHover: pauseOnHover, 3716 dragMinThreshold: { 3717 mouse: 4, 3718 touch: 10, 3719 }, 3720 direction: dir, 3721 3722 }); 3723 if (document.querySelector('.subnav-link-to-carousel')) { 3724 window.addEventListener('load', (event) => { 3725 this.splideMobileView(hero); 3726 }); 3727 } else { 3728 this.splideMobileView(hero); 3729 } 3730 } 3731} 3732function enableHorizontalWheelScroll(trackSelector, splideInstance, delay = 300) { 3733 var track = document.querySelector(trackSelector); 3734 let lastScrollTime = 0; 3735 3736 if (!track) return; // Exit if no track found 3737 3738 track.addEventListener('wheel', function (e) { 3739 // Check if horizontal movement is stronger than vertical 3740 if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) { 3741 e.preventDefault(); // Stop page scroll 3742 3743 const now = Date.now(); 3744 if (now - lastScrollTime > delay) { 3745 // Move only once per delay 3746 if (e.deltaX > 0) { 3747 splideInstance.go('>'); 3748 } else { 3749 splideInstance.go('<'); 3750 }
3751 lastScrollTime = now; 3752 } 3753 } 3754 // If vertical scroll is stronger, let page scroll normally 3755 }, { passive: false }); 3756} 3757document.addEventListener('DOMContentLoaded', function () { 3758 // add click event for elements which has 'wd-modal-btn' class 3759 var modalBtnEle = document.getElementsByClassName("wd-modal-btn"); 3760 for (var i = 0; i < modalBtnEle.length; i++) { 3761 modalBtnEle[i].addEventListener('click', showModalWindow, false); 3762 } 3763 3764 // add click event for elements which has 'wd-modal-btn' class 3765 var modalCloseEle = document.getElementsByClassName("wd-modal-close"); 3766 for (var i = 0; i < modalCloseEle.length; i++) { 3767 modalCloseEle[i].addEventListener('click', closeModalWindow, false); 3768 } 3769 3770 function closeModalWindow(element) { 3771 if(typeof element != 'undefined' && element.type != 'click'){ 3772 element.closest('.wd-modal').classList.add("hidden"); 3773 }else{ 3774 this.closest('.wd-modal').classList.add("hidden"); 3775 } 3776 document.body.classList.remove('overflow-hidden'); 3777 document.body.classList.remove('mob-minicart-open'); 3778 if (document.querySelector('.wd-modal-active')) { 3779 document.querySelector('.wd-modal-active').focus(); 3780 } 3781 if ( document.querySelector('.wd-modal-active')) { 3782 document.querySelector('.wd-modal-active').classList.remove('wd-modal-active'); 3783 } 3784 } 3785 function showModalWindow(e) { 3786 var modalId = this.getAttribute("data-target"); 3787 3788 e.target.classList.add("wd-modal-active") 3789 3790 if(typeof modalId == 'undefined' || !modalId){ 3791 modalId = this.getAttribute("href"); 3792 } 3793 modalId = (modalId && modalId.indexOf('#')>-1) ? modalId.replace('#','') : modalId; 3794 3795 var modalEle = document.getElementById(modalId); 3796 if (modalEle) { 3797 modalEle.classList.remove('hidden'); 3798 document.body.classList.add("overflow-hidden"); 3799 3800 var formElement = modalEle.getElementsByClassName('store-form'); 3801 // if modal has form then only load recaptcha script 3802 if(formElement.length>0 && !recaptchaScriptLoaded ){ 3803 loadRecaptchaScript(); 3804 } 3805 3806 if(formElement.length>0 && !formInit){ 3807 initializeFormEventHandlers(); 3808 } 3809 } 3810 } 3811 3812 //Skip To Content 3813 if ($(window).width() >= 992) { 3814 let skipToContentLabel = "Skip to main content"; 3815 if(document.getElementById("skipToMainContent") 3816 && document.getElementById("skipToMainContent").getAttribute("data-skipLabel")) { 3817 skipToContentLabel = document.getElementById("skipToMainContent").getAttribute("data-skipLabel"); 3818 }
3819 $("header").prepend("<a tabindex='0' class='skipBTN' role='link'>"+ skipToContentLabel +"</a>"); 3820 if($(".skipBTN").length){ 3821 $('.skipBTN').on('keyup', function(e) { 3822 if(e.keyCode == 13) { 3823 $('#skipToMainContent').focus(); 3824 } 3825 }); 3826 } 3827 } 3828 3829 function initStoreLeftNavFocus() { 3830 document.querySelectorAll('.store-content-listing-anchor').forEach(function (anchor) { 3831 // run only once per link 3832 if (anchor.getAttribute('data-focus-init') === 'true') { 3833 return; 3834 } 3835 anchor.setAttribute('data-focus-init', 'true'); 3836 3837 anchor.addEventListener('click', function () { 3838 var href = anchor.getAttribute('href') || ''; 3839 if (href.indexOf('#') !== 0 || href.length < 2) { 3840 return; 3841 } 3842 // the same id can exist twice on the page (desktop + mobile content), use the visible one 3843 var section = null; 3844 document.querySelectorAll('[id="' + href.substring(1) + '"]').forEach(function (el) { 3845 if (el.offsetParent !== null) { 3846 section = el; 3847 } 3848 }); 3849 if (!section) { 3850 return; 3851 } 3852 // prefer the section heading, otherwise the section itself 3853 var focusTarget = /^H[1-6]$/.test(section.tagName) 3854 ? section 3855 : (section.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]') || section); 3856 if (!focusTarget.hasAttribute('tabindex')) { 3857 focusTarget.setAttribute('tabindex', '-1'); // focusable by script only, no extra TAB stop 3858 focusTarget.classList.add('outline-none'); // Tailwind: no focus ring on the heading 3859 } 3860 focusTarget.focus({ preventScroll: true }); // scrolling is done by comp.js 3861 }); 3862 }); 3863 } 3864 document.addEventListener('DOMContentLoaded', initStoreLeftNavFocus); 3865}); 3866if($('.consumer-offer-form').length){ 3867 $('.contestmenu').removeClass('bg-red').addClass('bg-white text-red font-medium'); 3868 $('.termsAndConditionMenu,.winnersMenu').removeClass('bg-white text-red font-medium').addClass('text-white'); 3869} 3870if($('.termsAndCondition').length){ 3871 $('.termsAndConditionMenu').removeClass('bg-red').addClass('bg-white text-red font-medium'); 3872 $('.contestmenu,.winnersMenu').removeClass('bg-white text-red font-medium').addClass('text-white'); 3873} 3874if($('.winners').length){ 3875 $('.winnersMenu').removeClass('bg-red').addClass('bg-white text-red font-medium'); 3876 $('.termsAndConditionMenu,.contestmenu').removeClass('bg-white text-red font-medium').addClass('text-white'); 3877} 3878 3879//Parallax animation 3880 3881$(window).on('load', function () { 3882 if($('.wd-rellax').length){ 3883 var rellax = new Rellax('.wd-rellax', { 3884 speed: 2, 3885 }); 3886 } 3887 3888 if($('.wd-rellax-slow').length){ 3889 var rellax = new Rellax('.wd-rellax-slow', { 3890 speed: 1.32, 3891 }); 3892 } 3893 3894 if($('.wd-rellax-fast').length){ 3895 var rellax = new Rellax('.wd-rellax-fast', { 3896 speed: 2.66, 3897 }); 3898 } 3899});
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.