1//Global variables 2 3var MS = 30; //breakpoint (in em) between mobile portrait and mobile landscape (480px) 4var SM = 48; //breakpoint (in em) between mobile landscape and tablet (768px) 5var MD = 72; //breakpoint (in em) between tablet and small desktop (1152px) //#891191 6var LG = 84; //breakpoint (in em) between small desktop and large desktop (1344px) 7 8var breakpointMS; 9var breakpointSM; 10var breakpointMD; 11var breakpointLG; 12var windowWidth = $(window).width(); 13var windowHeight = window.innerHeight ? window.innerHeight : $(window).height(); //#748566 14var animationDuration = 400; 15var delayDropdownHide = 300; 16var delayDropdownShow = 400; 17var delaySubmenuShow = 300; //#908953 18var heightHeaderTotal = 0; 19var heightFilterBar = 0; 20var heightStickyTotal = 0; 21var heightFooter = 0; 22//#741050 START 23var menuLayout = $('html').data('menulayout'); 24var sidebarLayout = $('html').data('sidebarlayout'); 25//#741050 END 26var slickJsLoaded = false; //#891191 27 28//Set all breakpoint variables before loading document/window 29getBreakpointMatches(); 30 31//Functions to run after loading window 32$(window).on('load', function () { //#1032085 33 onLoadAndResize(); 34 onLoadAndBreakpointChange(); //#891191 35 loadHomepageLayout(); //Initialise OnePage, Alternative Onepage or Fullpage //#750324 MOVED 36 imagesBelowFold($(window).scrollTop()); 37 loadbrandlist(); 38 if ($('html').data('headertabs') == '1') loadOrShowMenu(); //#947809 39}); 40 41//Functions to run when window is resized (including rotated) 42$(window).resize(function () { 43 if ($(window).width() != windowWidth) { //Check genuine resize, not iOS triggering resize event on scroll 44 windowWidth = $(window).width(); //Update window width 45 windowHeight = $(window).height(); //Update window height 46 if (getBreakpointMatches() == true) onLoadAndBreakpointChange(); //#891191 47 onLoadAndResize(); 48 resizeHomepage(); //Resize OnePage, Alternative Onepage or Fullpage //#750324 ADDED 49 } 50}); 51 52function onLoadAndResize() { 53 initStickiness(); //Initialise elements that become sticky when scrolled to 54 eliteSlider(); //Initialise eliteSlider 55 equalize(); //Equalise heights of specified elements 56 accHeights(); //Initialise accordion body heights 57 initInfiniteOnScroll(); //Initialise infinite scroll + also does image reveal 58 moveFilter(); //Move filter between popup and sidebar 59 productLayout(); //Position price and images on product page 60 eliteScrollSpy(); //Initialise custom scrollspy 61 checkWishStatus(); 62 promoBanner(2000, 1000); 63 if (!breakpointSM) hideSearchDropdown(0); //#1008758 64 //#891191 REMOVED 65 positionCookieBar(); 66 //if (breakpointMD && prodzoom_control == 'on') {productZoom();} 67 setTimeout(function () { try {initStickinessCat('#listing-sidebar', '#listing-list', '');} catch(err) {} }, 200); 68 initBackToTopButton(); //Initialise Back To Top button 69 miniBasketHeightAdjust(); 70 $('[data-src-large][data-src-small]').not('[data-revealsrc]').each(function () { chooseImage($(this)[0]); }); //#750324 71 initiateContentSpots(); //#778360 72 initExpandable(); //#955370 73 74 75 76} 77 78//#891191 START 79function onLoadAndBreakpointChange() { 80 initPdpImageScrollVertical(); 81 initScrollSpy(); 82} 83//#891191 END 84 85$(document).on('click', '[data-url]:not(.addthis_inline_share_toolbox)', function (e) { location.href = $(this).data('url'); }); 86 87$(document).ready(function () { 88 89 90 const $body = $('body'); 91 $body.addClass('using-mouse'); 92 93 $(document).on('keydown', function (e) { 94 if (e.key === 'Tab') { 95 $body.removeClass('using-mouse'); 96 } 97 });
98 99 $(document).on('mousedown', function () { 100 $body.addClass('using-mouse'); 101 }); 102 103 $('[data-video]').click(function (e) { 104 $('#videoholder').html('<iframe allowfullscreen="" src="' + $(this).data('video') + '?autoplay=1"></iframe>'); 105 popup('videopopup'); 106 }); 107 108 $('input[type=text], input[type=number]').focus(function () { 109 $(this).select().mouseup(function (e) { 110 e.preventDefault(); 111 $(this).unbind('mouseup'); 112 }); 113 }); 114 115 $('.plus,.minus').click(function () { $(this).toggleClass('plus minus').not('[onclick]').next().slideToggle(); }); 116 117 //MAKE PARENT TALL ENOUGH TO ACCOMODATE POPOUT WHEN ACCORDION IS FULLY OPEN 118 $('.popout').each(function () { 119 var popout = $(this); 120 popout.find('.plus').click(); //accordion fully open 121 setTimeout(function () { //wait for accordion animation to complete 122 popout.parent().css('min-height', popout.height() + 16 + 'px'); //measure popout height and set parent min-height 123 popout.find('.minus').click(); //accordion fully closed 124 }, 1000); 125 }); 126 127 //POPUP CLOSE - click 'x' or background 128 $('#overlay, .popup-close').click(function () { popupClose(); }); 129 130 //POPOUT OPEN 131 $('.popout-open').click(function () { $('.popout').addClass('show'); $(this).addClass('hide'); }); 132 133 //POPOUT CLOSE 134 $('.popout-close').click(function () { $('.popout').removeClass('show'); $('.popout-open').removeClass('hide'); }); 135 136 $('.VideoLINKSbox iframe').each(function () { var url = $(this).attr('src'); $(this).attr('src', url + '?wmode=transparent'); }); 137 138 //TAB WIDTHS 139 tabWidths(); 140 141 //#700114 - START 142 //BUGFIELDS: FIELDS TRIGGERING SOFT KEYPAD OR OTHER iOS NATIVE COMPONENT 143 var bugFields = $('input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"], select, textarea'); 144 145 if (iDevice) { 146 //WORKAROUND FOR IPHONE/IPAD'S LOSS OF FIXED POSITIONING WHEN KEYBOARD APPEARS: ALL BUGFIELDS NOT IN HEADER/FOOTER 147 bugFields.not($('.exclude-from-bugfields')).focus(function () { if (breakpointSM) { $('body').addClass('showdropdown'); deactivateAllStickiness(); } }); 148 bugFields.not($('.exclude-from-bugfields')).blur(function () { if (breakpointSM) { $('body').removeClass('showdropdown'); toggleAllStickiness(); } }); 149 } 150 151 //WORKAROUND FOR IPHONE/IPAD'S ZOOM WHEN KEYBOARD APPEARS: ALL BUGFIELDS 152 bugFields.focus(function () { $('meta[name="viewport"]').attr('content', 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0'); }); 153 bugFields.blur(function () { $('meta[name="viewport"]').attr('content', 'width=device-width,initial-scale=1'); }); 154 //#700114 - END 155 156 if (iDevice) { $('html').addClass('idevice'); } else { $('html').addClass('no-idevice'); } 157 if (webKit) { $('html').addClass('webkit'); } else { $('html').addClass('no-webkit'); } 158 159 //#891191 160 $('.tabgroup .tab:not(.linktab)').click(function () { 161 var toggleSpeed = breakpointSM ? 0 : 400; 162 $(this).siblings('.tab:not(.linktab)').removeClass('selected').next().slideUp(toggleSpeed); 163 $(this).addClass('selected').next().slideDown(toggleSpeed); 164 }); 165}); 166 167function loadbrandlist(){ 168 //ISOTOPE ON BRANDS PAGE 169 if ($('#brandscontainer').length == 1) { 170 var $con = $('#brandscontainer').isotope({ layoutMode: 'fitRows', filter: '.popbrand' }); 171 $('#brandfilters span').click(function () { 172 var filterValue = $(this).attr('data-filter'); 173 $(this).addClass('current').siblings('span').removeClass('current'); 174 $con.isotope({ layoutMode: 'fitRows', filter: filterValue }); 175 }); 176 } 177} 178 179function popupClose() { 180 $('#overlay').fadeOut(); 181 $('.popup, .popup-fixedSM, .popout-right').fadeOut(); //#891191, #908953 182 $('#ajaxVideo').html(''); 183 $('#videoholder').html(''); 184} 185 186function equalizeUtility(group) { 187 group.height('auto'); 188 var maxH = 0; 189 group.each(function () { if ($(this).height() > maxH) { maxH = $(this).height(); } }); 190 group.height(maxH); 191} 192 193function equalize() { 194 $('.equalized').each(function () { equalizeUtility($(this).children()); }); 195
196 equalizeUtility($('.equalized-these')); //use only once per page 197 equalizeUtility($('.equalized-these-1')); //use only once per page 198 equalizeUtility($('.equalized-these-2')); 199 equalizeUtility($('.equalized-these-item')); 200 equalizeUtility($('.equalized-searchdrop-item')); 201 if (breakpointSM) { 202 equalizeUtility($('.equalized-these-notnarrow')); //use only once per page 203 equalizeUtility($('.equalized-these-notnarrow-1')); //use only once per page 204 } 205} 206 207function tabWidths() { 208 $('.tabwidth-jquery').each(function () { 209 var tabs = $(this).find('.tab'); 210 var left = 0; 211 for (i = 1; i < tabs.length; i++) { 212 if (tabs.eq(i - 1).css('display') != 'none') { 213 left += tabs.eq(i - 1).outerWidth(true); 214 } 215 tabs.eq(i).css('left', left); 216 } 217 }); 218} 219 220//#955228 START 221function popup(id, callback) { 222 var pop = $('#' + id); 223 224 //set approximate initial position to minimise jump, based on min popup height 225 var t = $(window).scrollTop() + $(window).height() / 2 - 125; 226 //if (id == 'ajaxPRODUCT') t -= 165; 227 if (id == 'ajaxPRODUCTcontainer') t -= 165; 228 if (id == 'ajaxFinance') t -= 136; 229 if (id == 'ajaxEditorial') t -= 125; 230 if (id == 'filterpopup') { t = 32; $('#filters-copy').html($("#YouAreHere").html()); } 231 pop.css('top', t); 232 233 $('#overlay').fadeIn(); 234 $('body').addClass('popwindow'); 235 pop.fadeIn(function () { 236 popupAdjust(id); 237 if (callback) setTimeout(callback, parseFloat(pop.css('transition-duration'))*1000); //CONVERT 0.75 SECONDS TO 750 MILLISECONDS 238 }); 239} 240//#955228 END 241 242function popupFixed(div) { $('#' + div + ', #overlay').fadeIn(); } //#891191 243 244function popupAdjust(id) { 245 var pop = $('#' + id); 246 247 //set popup's position more accurately 248 var popHeight = pop.height(); 249 var popCloseHeight = pop.find('.popup-close').height(); 250 var popMargin = 10; 251 var maxPopHeight = windowHeight - popCloseHeight - (2 * popMargin); 252 if (popHeight < maxPopHeight) { pop.css('top', $(window).scrollTop() + (windowHeight - popHeight) / 2 + 'px'); } 253 else { 254 pop.css('top', $(window).scrollTop() + popMargin + popCloseHeight + 'px'); 255 if (breakpointSM) { pop.height(maxPopHeight); pop.children('.autooverflow-y').height(maxPopHeight); } 256 } 257} 258 259function checkForVideoResize() { 260 $(".vimeo-video").each(function (index) { 261 if ($(this).html() == '') { 262 if ($(this).attr("data-src") != '') urlToUse = 'http://player.vimeo.com/video/' + $(this).attr('data-src') + '?autoplay=1&loop=1&color=1f3340&title=0&byline=0&portrait=0'; 263 } 264 }); 265 266} 267 268//#707331 269function runHomeSwiper(slideinterval, slidespeed, homeSwiper) { 270 if ($('.home-swiper-wrapper').length > 0) { 271 if ($('.home-swiper-wrapper > *').length > 1) { 272 273 $('.home-swiper-wrapper > *').wrap('<div class="home-swiper-slide"></div>').find('[data-revealsrc]').each(function () { 274 $(this).attr('src', $(this).attr('data-revealsrc')).removeAttr('data-revealsrc'); 275 }); 276 $('.home-swiper-previous, .home-swiper-next').removeClass('hidden'); 277 $('.home-swiper-previous, .home-swiper-next').addClass('showonwide'); 278 279 var homeSwiper = new Swiper('.home-swiper-container1', { 280 effect:"slide", 281 speed: slidespeed, 282 spaceBetween: 0, 283 loop: true, 284 slidesPerView:1, 285 //autoplay: slideinterval, 286 containerModifierClass : 'home-swiper-container1', 287 slideClass : 'home-swiper-slide', 288 wrapperClass : 'home-swiper-wrapper', 289 nextButton: '.home-swiper-next', 290 prevButton: '.home-swiper-previous', 291 pagination: '.home-swiper-pagination1', 292 paginationClickable: true, 293 centeredSlides: true, 294 paginationBulletRender: function (index, className) { 295 return '<span class="' + className + '">' + (index + 1) + '</span>'; 296 } 297 298 }); 299 300 301 //$('.home-swiper-previous').on('click', function (e) { e.preventDefault(); mySwiper.slidePrev(); }); 302 //$('.home-swiper-next').on('click', function (e) { e.preventDefault(); mySwiper.slideNext(); }); 303 304 305 }else{ 306 try { 307 $('.home-swiper-wrapper > *').unwrap('<div class="home-swiper-slide"></div>').find('[data-revealsrc]').each(function () { 308 $(this).attr('src', $(this).attr('data-revealsrc')).removeAttr('data-revealsrc'); 309 }); 310 } catch(err) { 311 } 312 $('.home-swiper-previous, .home-swiper-next').addClass('hidden'); 313 $('.home-swiper-previous, .home-swiper-next').removeClass('showonwide'); 314 $('.home-swiper-previous, .home-swiper-next').hide(); 315 } 316} 317} 318 319function homeProductSwiper(selector, slidespeed) { 320 321 if ($('#'+ selector + ' .home-swiper-slide').length == 0) { 322 $('#'+ selector + ' .home-swiper-wrapper > div').addClass('home-swiper-slide'); 323 $('#'+ selector + ' .home-swiper-previous,' + selector + ' .home-swiper-next').removeClass('hidden'); 324 } 325 326 $('#'+ selector + ' .home-swiper-slide').find('[data-revealsrc]').each(function () { 327 $(this).attr('src', $(this).attr('data-revealsrc')).removeAttr('data-revealsrc'); 328 }) 329
330 var objSwiperBreakpoints = {}; //object built up piece by piece as IE dosen't support shorter notation 331 objSwiperBreakpoints[(MS * 16) - 1] = { slidesPerView: 2 }; //breakpoint between mobile portrait and mobile landscape in format usable by Swiper 332 objSwiperBreakpoints[(SM * 16) - 1] = { slidesPerView: 3 }; //breakpoint between mobile landscape and tablet in format usable by Swiper 333 objSwiperBreakpoints[(MD * 16) - 1] = { slidesPerView: 4 }; //breakpoint between mobile landscape and tablet in format usable by Swiper 334 335 var prodswiper = new Swiper('#'+ selector + ' .home-swiper-container', { 336 speed: slidespeed, 337 loop: true, 338 spaceBetween: 10, 339 prevButton:'.prod-swiper-previous', 340 nextButton:'.prod-swiper-next', 341 containerModifierClass :'home-swiper-container', 342 slideClass :'home-swiper-slide', 343 wrapperClass :'home-swiper-wrapper', 344 pagination:'.home-swiper-pagination', 345 slidesPerView: 4, 346 breakpoints: objSwiperBreakpoints 347 }); 348 $('#'+ selector + ' .prod-swiper-previous').on('click', function (e) { e.preventDefault(); prodswiper.slidePrev(); }); 349 $('#'+ selector + ' .prod-swiper-next').on('click', function (e) { e.preventDefault(); prodswiper.slideNext(); }); 350 351} 352 353function runproductswiper(myswiper) { 354 if ($('#' + myswiper + ' .swiper-wrapper > *').length > 1) { 355 $('.swiper-wrapper > *').wrap('<div class="swiper-slide"></div>').find('[data-revealsrc]').each(function () { 356 $(this).attr('src', $(this).attr('data-revealsrc')).removeAttr('data-revealsrc'); 357 }); 358 359 if ($('html').hasClass('ie9')) { 360 //IE9 uses Swiper 2.7.0 (later versions not compatible) 361 var productSwiper; 362 363 if ($(window).width() >= 1300) { 364 productSwiper = new Swiper('.swiper-container', { mode: 'horizontal', speed: 500, loop: true, slidesPerView: 'auto', loopedSlides: 12, centeredSlides: true, keyboardControl: true, resizeReInit: true, roundLengths: true, onImagesReady: function () { swiperResize(); } }); 365 } else { 366 productSwiper = new Swiper('.swiper-container', { mode: 'horizontal', speed: 500, loop: true, slidesPerView: 'auto', loopedSlides: 12, centeredSlides: false, keyboardControl: true, resizeReInit: true, roundLengths: true, onImagesReady: function () { swiperResize(); } }); 367 } 368 $('.swiper-previous').on('click', function (e) { e.preventDefault(); productSwiper.swipePrev(); }); 369 $('.swiper-next').on('click', function (e) { e.preventDefault(); productSwiper.swipeNext(); }); 370 swiperResize(); 371 productSwiper.resizeFix(true); 372 373 } else { 374 //All other browsers use latest version of Swiper 375 var sPV = 'auto'; //#908953 376 if ($('[data-pdpimagesscrollsingle="1"]').length == 1) sPV = 1; //#908953 377 var swiperParams = { 378 speed: 500, 379 loop: true, 380 slidesPerView: sPV, //#908953 381 centeredSlides: false, 382 keyboardControl: true, 383 pagination: '.prodswiper-pagination', 384 paginationClickable: true, 385 //slideToClickedSlide: true, 386 nextButton: '.swiper-next', 387 prevButton: '.swiper-previous', 388 onInit: function (productSwiper) { swiperOnInit(); }, 389 onTransitionEnd: function (productSwiper) { updateEnlargeLink(); } 390 } 391 if (windowWidth >= 1300) swiperParams.centeredSlides = true; 392 var productSwiper = new Swiper('.swiper-container', swiperParams); 393 } 394 395 }else{ 396 //#908953 397 //$('#' + myswiper + ' .swiper-wrapper > *').unwrap('<div class="swiper-slide"></div>').find('[data-revealsrc]').each(function () { 398 $('#' + myswiper + ' .swiper-wrapper > .swiper-slide').removeClass('swiper-slide').find('[data-revealsrc]').each(function () { 399 $(this).attr('src', $(this).attr('data-revealsrc')).removeAttr('data-revealsrc'); 400 }); 401 $('#' + myswiper + ' .swiper-wrapper, #' + myswiper + ' .noswi
401per-container .swiper-wrapper').attr('style', ''); //#922219 402 } 403} 404 405function swiperOnInit() { 406 valProductVideo(); 407 updateEnlargeLink(); 408} 409 410function valProductVideo() { 411 if ($('.product-video').length > 0) { 412 $('#myvideolink').removeClass('hidden-important'); 413 slideToVideo(); 414 $('video').click(function(){ 415 $(this).get(0).play(); 416 }); 417 } else { 418 $('#myvideolink').addClass('hidden-important'); 419 } 420} 421 422function updateEnlargeLink(){ 423 var oldImg = $('#productmainimage').find('.swiper-slide-active .productasset'); 424 var newImg = ""; 425 if(oldImg.hasClass('product-video')){ 426 oldImg.children('video').get(0).play(); 427 newImg = ""; 428 $('#showEnlargeimage').fadeOut(200); 429 }else{ 430 newImg = oldImg.attr('src').replace('/medium/','/large/'); 431 if ($('#productmainimage').find('.swiper-slide .productasset').children('video').length > 0) { 432 $('#productmainimage').find('.swiper-slide .productasset').children('video').each(function(index, element) { 433 $(this).get(0).pause(); 434 }); 435 } 436 $('#showEnlargeimage').fadeIn(200); 437 } 438 $('#showEnlargeimage').attr('href', newImg); 439 440 if (breakpointSM) { 441 $('#productmainimage .swiper-slide-active img').off('click').on('click', function() { //#955228 PREVENT FROM TRIGGERING TWICE 442 $('#showEnlargeimage').trigger('click'); 443 }) 444 } 445} 446 447function slideToVideo(){ 448 $('#myvideolink').on('click', function (e){ 449 $('.prodswiper-pagination > span:last-child').trigger('click'); 450 }); 451} 452 453//SWIPER RESIZE FUNCTION - comes directly from iDangero.us example code - do not edit 454function swiperResize() { 455 $('.swiper-slide').css('width', ''); 456 var imgWidth = $('.swiper-slide img').width(); 457 if (imgWidth > $(window).width()) imgWidth = $(window).width(); 458 $('.swiper-slide').css('width', imgWidth); 459} 460 461function scrollTo(pos) { $('html, body').stop(false, false).animate({ scrollTop: pos - $('#masthead').height() }, 1000); } 462function goToByScroll(id) { $('html,body').animate({ scrollTop: $('#' + id).offset().top }, '100'); } 463function goToByScrollExHead(id) { $('html,body').animate({ scrollTop: $('#' + id).offset().top - $('header').height() }, '100'); } 464 465//Stickiness 466function getHeights() { 467 heightHeaderMain = $('#header-main').outerHeight(); //#741050 468 heightHeaderTotal = heightHeaderMain + $('[data-menulayout="dropdown"]:not([data-header="4"]):not([data-header="5"]):not([data-header="6"]) #nav-level0').outerHeight(); //#741050, #965710, #1008758 469 heightFilterBar = $('#stickyFilterBar').outerHeight(); 470 heightStickyTotal = heightHeaderTotal + heightFilterBar; //used in eliteInfinite 471 if ($('[data-staticfooter="1"], [data-staticfooter="2"]').length == 0) heightFooter = $('footer').outerHeight(); //sticky footer only #1008758 472} 473 474function initStickiness() { 475 if (breakpointSM && !$('html').hasClass('onepage') && !$('body').hasClass('slidingmenu')) { //#750324 476 getHeights(); 477 toggleAllStickiness(); 478 $(window).on('scroll', stickinessScroll); 479 } else { 480 deactivateAllStickiness(); 481 $(window).off('scroll', stickinessScroll); 482 } 483} 484 485//#955345 486function reinitStickiness() { 487 deactivateAllStickiness(); 488 $(window).off('scroll', stickinessScroll); 489 initStickiness(); 490} 491 492function stickinessScroll() { if (!$('body').hasClass('showdropdown')) toggleAllStickiness(); } 493 494//#891191 START 495function toggleAllStickiness() { 496 if (siteBrandId != "mon"){ 497 toggleElementStickiness($('#header-main'), $('#stickyHeaderMainGap'), 0); 498 toggleElementStickiness($('[data-menulayout="dropdown"] #nav-level0'), $('#header-nav'), $('[data-header="4"],[data-header="5"],[data-header="6"]').length == 1 ? 0 : heightHeaderMain); //#741050, #965710, #1008758 499 } 500 501 toggleElementStickiness($('#stickyFilterBar'), $('#stickyFilterBarGap'), heightHeaderTotal - 1, undefined, filterbarCallback); 502 toggleElementStickiness($('#pagination'), $('#stickyPaginationGap'), heightHeaderTotal + heightFilterBar); 503 toggleElementStickiness($('#alternativeImages'), $('#alternativeImagesPlaceholder'), heightHeaderTotal - 1, $('#mainImages')); 504 toggleElementStickiness($('.imagescrollvertical-details'), $('#productDetailsPlaceholder'), heightHeaderTotal - 1, $('#mainImages')); 505 506 507 toggleElementStickiness($('#stickyFilterBarx'), $('#stickyFilterBarGap'), heightHeaderTotal - 1, undefined, filterbarCallback); 508 509} 510 511function toggleElementStickiness(targetElement, placeholderElement, targetPosition, limitingElement, callback) { 512 if (placeholderElement.length == 1) { 513 var placeholderYcoord = placeholderElement[0].getBoundingClientRect().top; //y-coordinate with respect to viewport 514 if (placeholderYcoord <= targetPosition && !targetElement.hasClass('fixed') && (!targetElement.hasClass('absolute') || typeof limitingElement == 'undefined')) { //scrolled down past placeholder 515 //position target at top of viewport (if taller than limiting element where applicable) 516 if (typeof limitingElement == 'undefined') { 517 activateElementStickiness(targetElement, placeholderElement, targetPosition, callback); 518 } else if (limitingElement.height() > targetElement.height()) { 519 activateElementStickiness(targetElement, placeholderElement, targetPosition, callback); 520 } 521 } 522 if (targetElement.hasClass('fixed')) { 523 if (placeholderYcoord > targetPosition) { //scrolled up past placeholder 524 deactivateElementStickiness(targetElement, placeholderElement, callback); 525 if (typeof limitingElement != 'undefined') targetElement.removeClass('absolute'); 526 } else if (typeof limitingElement != 'undefined') { 527 if (targetElement[0].getBoundingClientRect().bottom > limitingElement[0].getBoundingClientRect().bottom) { //target reached bottom of limiting element 528 deactivateElementStickiness(targetElement, placeholderElement, callback); 529 targetElement.css({ 'bottom': 0, 'width': targetElement.outerWidth() }).addClass('absolute'); //position target at bottom of relative ancestor 530 } 531 } 532 } 533 if (typeof limitingElement != 'undefined' && targetElement.hasClass('absolute') && targetElement[0].getBoundingClientRect().top > targetPosition) { //scrolled up from bottom of limiting element 534 targetElement.css({ 'bottom': '' }).removeClass('absolute'); 535 activateElementStickiness(targetElement, placeholderElement, targetPosition, callback); 536 } 537 } 538} 539 540function activateElementStickiness(targetElement, placeholderElement, targetPosition, callback) { 541 placeholderElement.height(targetElement.height()); 542 targetElement.css({ 'top': targetPosition, 'width': targetElement.outerWidth() }).addClass('fixed'); 543 if (callback) callback(true); 544} 545 546function deactivateAllStickiness() { 547 deactivateElementStickiness($('#header-main'), $('#stickyHeaderMainGap')); 548 deactivateElementStickiness($('[data-menulayout="dropdown"] #nav-level0'), $('#header-nav')); 549 deactivateElementStickiness($('#stickyFilterBar'), $('#stickyFilterBarGap')); 550 deactivateElementStickiness($('#pagination'), $('#stickyPaginationGap')); 551 deactivateElementStickiness($('#alternativeImages'), $('#alternativeImagesPlaceholder')); 552 deactivateElementStickiness($('.imagescrollvertical-details'), $('#productDetailsPlaceholder')); 553 554 deactivateElementStickiness($('#stickyFilterBarx'), $('#stickyFilterBarGap')); 555} 556 557function deactivateElementStickiness(targetElement, placeholderElement, callback) { 558 targetElement.removeClass('fixed').css({ 'top': '', 'bottom': '', 'width': '' }); 559 placeholderElement.height(''); 560 if (callback) callback(false); 561} 562 563function filterbarCallback(active) { 564 var scale = $('.icon-logo')[0].getBoundingClientRect().width / $('.icon-logo')[0].offsetWidth; 565 if (active && scale > 1.4) { 566 $('.icon-logo').css('transform', 'scale(1.4)'); 567 } else { 568 $('.icon-logo').css('transform', ''); 569 } 570} 571//#891191 END 572 573//Don't print footer on every sheet 574$(window).bind('beforeprint', function () { preventStickiness(); }); 575 576//Isotope 577$(document).ready(function () { 578 if ($('.grid').length > 0) { 579 $('.grid').isotope({ itemSelector: '.grid-item' }); 580 } 581}); 582 583//Sliding footer sections 584$(document).on('click', '.footer-tab', function () { 585 if ($(this).parent().hasClass('current')) { 586 hideFooter($(this).parent()); 587 } else { 588 //hide any currently displayed footer section 589 oldFooter = $(this).parent().siblings('.current'); 590 if (oldFooter.length > 0) { hideFooter(oldFooter); } 591 592 //show required footer item 593 newFooter = $(this).parent(); 594 newFooter.addClass('current'); 595 if (!breakpointSM) $(this).next('.footer-slidingsection').slideDown(); 596 597 if (breakpointSM) $('#overlay-footer').fadeIn(400).on('click', function () { hideFooter(newFooter); }); 598 } 599 600}); 601function hideFooter(f) { 602 f.removeClass('current');
603 if (!breakpointSM) f.find('.footer-slidingsection').slideUp(); 604 $('#overlay-footer').fadeOut().off(); 605 f.off(); 606} 607 608//Accordion 609var dataHeight = 158; 610function accHeights() { 611 $('.acc-item.active').removeClass('active'); 612 $('.acc-extend').hide(); 613 if (breakpointSM) { 614 $('.acc-text').each(function () { if ($(this).find('.acc-header').outerHeight() + $(this).find('.acc-body').outerHeight() > dataHeight) $(this).siblings('.acc-extend').show(); }); 615 } 616} 617$(document).on('click', '.acc-header', function (e) { 618 var thisItem = $(this).parents('.acc-item'); 619 if (!breakpointSM && thisItem.find('.acc-body').length == 1) { 620 e.preventDefault(); 621 thisItem.toggleClass('active').find('.acc-body').slideToggle(); 622 thisItem.parents('.accordion').find('.acc-item.active').not(thisItem).removeClass('active').find('.acc-body').slideUp(); 623 } 624}); 625$(document).on('click', '.acc-extend', function (e) { 626 if (breakpointSM) { 627 var clickedItem = $(this).parents('.acc-item'); 628 if (clickedItem.hasClass('active')) { clickedItem.accText('close'); } 629 else { $('.acc-item.active').accText('close'); clickedItem.accText('open'); } 630 } 631}); 632$.fn.accText = function (action) { 633 var thisItem = this; 634 var thisText = this.find('.acc-text'); 635 if (action == 'open') { 636 thisItem.addClass('active'); 637 //measure new height by temporarily invisibly displaying it 638 thisText.addClass('invisible extended'); 639 var newHeight = thisText.height(); 640 thisText.removeClass('invisible extended'); 641 //animate to new height 642 thisText.animate({ height: newHeight }, function () { thisText.addClass('extended').height(''); }); 643 } 644 if (action == 'close') { 645 //measure new height by temporarily invisibly displaying it 646 thisText.addClass('invisible').removeClass('extended'); 647 var newHeight = thisText.height(); 648 thisText.removeClass('invisible').addClass('extended'); 649 //animate to new height 650 thisText.animate({ height: newHeight }, function () { thisText.removeClass('extended').height(''); thisItem.removeClass('active'); }); 651 } 652 return this; 653} 654 655//Dropdowns 656$(document).on('click', '.droplink', function (e) { 657 hideAllDropdownsExcept('dropdiv'); 658 $('.droplink').not($(this)).removeClass('current').next('.dropdiv').slideUp(100); 659 $(this).toggleClass('current').next('.dropdiv').slideToggle(200); 660}); 661 662//SEARCH 663$(document).on('click', '.slidingsearch-open', function () { showSearch(); }); 664$(document).on('click', '.slidingsearch-close', function () { hideSearch(); }); 665 666//Basket dropdown #1008758 667$(document).on('click', '.slidingbasket-open', function () { showBasketDropdown(); }); 668$(document).on('click', '.slidingbasket-close, .slidingbasket-close-overlay', function () { hideBasketDropdown(animationDuration); repaint($('header')); }); //#946736 669 670//Utility functions 671function getBreakpointMatches() { 672 //#891191 START 673 breakpointMS = window.matchMedia('(min-width:' + MS + 'em)').matches; 674 breakpointSM = window.matchMedia('(min-width:' + SM + 'em)').matches; 675 breakpointMD = window.matchMedia('(min-width:' + MD + 'em)').matches; 676 breakpointLG = window.matchMedia('(min-width:' + LG + 'em)').matches; 677 if (typeof bpMatchesNew == 'undefined') { 678 bpMatchesNew = [breakpointMS, breakpointSM, breakpointMD, breakpointLG]; 679 return true; 680 } else { 681 var bpMatchesOld = bpMatchesNew; 682 bpMatchesNew = [breakpointMS, breakpointSM, breakpointMD, breakpointLG]; 683 if (bpMatchesOld < bpMatchesNew || bpMatchesOld > bpMatchesNew) return true; 684 } 685 //#891191 END 686} 687 688function noGaps() { 689 $('[class*="container-"],.row,.no-gaps,.nogaps').contents().filter(function () { return (this.nodeType == 3 && !/\S/.test(this.nodeValue)); }).remove(); 690} 691 692//#946736 693function repaint(el) { 694 el.css('transform', 'scale(0.9999999)'); 695 setTimeout(function() { el.css('transform', ''); }, 2000); 696} 697 698function eliteSlider() { 699 $(".eliteSlider").each(function () { 700 var sliderInstance = $(this); 701 eliteSliderIndividual(sliderInstance); 702 });
703} 704 705function eliteSliderIndividual(slider) { 706 slider.removeClass('visible'); 707 708 var arrowPrev = slider.find('.elitePrev').removeClass('hidden').off(); //remove old click function 709 var arrowNext = slider.find('.eliteNext').removeClass('hidden').off(); 710 711 var slidecontainer = slider.find('.eliteSlides'); 712 slidecontainer.contents().filter(function () { return (this.nodeType == 3 && !/\S/.test(this.nodeValue)); }).remove(); //remove gaps from between slides 713 slidecontainer.removeAttr('style'); 714 715 var slides = slidecontainer.children(); 716 slides.removeAttr('style'); 717 var countSlides = slides.length; 718 719 var n; //number of slides to show at once 720 if (breakpointMD) { n = slider.data('slides-md'); } 721 else if (breakpointSM) { n = slider.data('slides-sm'); } 722 else if (breakpointMS) { n = slider.data('slides-ms'); } 723 else { n = slider.data('slides-xs'); } 724 725 if (countSlides > n) { 726 function resetSlides() { 727 slides.hide(); //hide all slides 728 slides = slidecontainer.children(); //reinitialise slide order 729 slidecontainer.css('left', 0); 730 for (var i = 0; i < n; i++) { slides.eq(i).show(); } //show 1st n slides 731 //alert(countSlides) 732 } 733 734 var arrowWidth = arrowPrev.outerWidth(true); 735 var slideWidth = (slider.width() - 2 * arrowWidth) / n; 736 slidecontainer.removeAttr('class').addClass('eliteSlides container-' + (n + 1) + 'x1'); //increase container capacity by 1 slide 737 slidecontainer.width((slideWidth * (n + 1)) + (2 * arrowWidth)).css({ 'paddingLeft': arrowWidth, 'paddingRight': arrowWidth }); //increase container width by 1 slide 738 resetSlides(); 739 740 arrowPrev.click(function () { $(slides).eq(-1).prependTo(slidecontainer).show(); slidecontainer.css('left', -slideWidth); slidecontainer.animate({ 'left': 0 }, function () { resetSlides(); }); }); 741 arrowNext.click(function () { $(slides).eq(n).show(); slidecontainer.animate({ 'left': -slideWidth }, function () { $(slides).eq(0).appendTo(slidecontainer); resetSlides(); }); }); 742 743 slider.on('swipeleft', function () { arrowNext.click(); }); 744 slider.on('swiperight', function () { arrowPrev.click(); }); 745 746 } else { 747 slidecontainer.removeAttr('class').addClass('eliteSlides slides-lte-n container-' + n + 'x1'); 748 arrowPrev.addClass('hidden'); 749 arrowNext.addClass('hidden'); 750 } 751 752 slider.addClass('visible'); 753} 754 755//Search dropdown 756$(document).on('focus', '#searchINPUT', function (e) { generateSearchdrop();}); 757$(document).on('keyup', '#searchINPUT', function (e) { generateSearchdrop(); if(e.which == 27) {hidesearchtimeout = setTimeout(hideSearchDropdown, 400);}}); 758$(document).on('click', '#searchINPUT', function () { mainSearchDropFunctionCall(); }); 759$(document).on('click', function (e) { 760 if ($(e.target).closest("#searchdrop").length === 0 && $(e.target).closest("#searchINPUT").length === 0) { 761 hidesearchtimeout = setTimeout(hideSearchDropdown, 400); 762 } 763}); 764$(document).on('keyup', function (e) {if(e.which == 27) {hidesearchtimeout = setTimeout(hideSearchDropdown, 400);}}); 765 766//SLIDING FACET SIDEBAR 767//#891191 START 768$(document).on('click', '.filter-plus,.filter-minus', function () { 769 if (breakpointSM && $('[data-filterpopupwide="1"],[data-filterright="1"]').length == 0) { //#908953 770 $('.container-sidebar-listing').toggleClass('sidebar-visible').promise().done(function () { 771 $('#filterdiv').toggleClass('invisible'); imagesBelowFold(999999999); 772 }); //#832366 773 $(this).toggleClass('filter-plus filter-minus').children('[class*=icon-filter-]').toggleClass('icon-filter-plus icon-filter-minus'); //#793851 774 } else { 775 popup('filterpopup'); 776 } 777 initSimplebarFacets(); 778}); 779 780 781 782 783 784 785 786 787function initSimplebarFacets() { 788 if (breakpointSM) { 789 if ($('html.webkit').length == 0) { 790 if (typeof SimpleBar == 'undefined') { 791 var s = document.createElement('script'); 792 s.src = '/javascript/simplebar.min.js'; 793 var t = document.getElementsByTagName('script')[0]; 794 t.parentNode.insertBefore(s, t); 795 $(s).on('load', function () { 796 $('.scroll-pane').each(function () { 797 var el = new SimpleBar(this); 798 el.getContentElement(); 799 }); 800 }); 801 } else { 802 $('.scroll-pane').each(function () { 803 var el = new SimpleBar(this); 804 el.getContentElement(); 805 }); 806 } 807 } 808 } 809} 810 811$(document).on('click', '.facetheader', function () { if (!breakpointSM) { $(this).next().slideToggle(); $(this).children('.fa').toggleClass('fa-angle-right fa-angle-down'); } }); 812//#891191 END 813 814// SET UP INFINITE SCROLLING - ONSCROLL EVENT - applies to both blogs / search / listings etc. 815function initInfiniteOnScroll() { 816 try { 817 window.onscroll = infiniteScrollingDetection; 818 } catch(err) { 819 } 820} 821 822//Filter from sidebar to popup and vice versa 823function moveFilter() { 824 if (breakpointSM && $('[data-filterpopupwide="1"],[data-filterright="1"]').length == 0) { $('#filterpopup #siblingcategorylinks,#filterpopup #facetMiddleBlock').appendTo('#filterdiv'); } //#891191, #908953 825 else { $('#filterdiv #siblingcategorylinks,#filterdiv #facetMiddleBlock').appendTo('#filterpopup'); } 826} 827 828/*! modernizr 3.3.1 (Custom Build) | MIT * 829* http://modernizr.com/download/?-csscolumns-flexbox-flexboxlegacy-flexboxtweener-touchevents-setclasses !*/ 830!function (e, n, t) { function o(e, n) { return typeof e === n } function r() { var e, n, t, r, s, i, a; for (var l in x) if (x.hasOwnProperty(l)) { if (e = [], n = x[l], n.name && (e.push(n.name.toLowerCase()), n.options && n.options.aliases && n.options.aliases.length)) for (t = 0; t < n.options.aliases.length; t++) e.push(n.options.aliases[t].toLowerCase()); for (r = o(n.fn, "function") ? n.fn() : n.fn, s = 0; s < e.length; s++) i = e[s], a = i.split("."), 1 === a.length ? Modernizr[a[0]] = r : (!Modernizr[a[0]] || Modernizr[a[0]] instanceof Boolean || (Modernizr[a[0]] = new Boolean(Modernizr[a[0]])), Modernizr[a[0]][a[1]] = r), g.pu
830sh((r ? "" : "no-") + a.join("-")) } } function s(e) { var n = b.className, t = Modernizr._config.classPrefix || ""; if (w && (n = n.baseVal), Modernizr._config.enableJSClass) { var o = new RegExp("(^|\\s)" + t + "no-js(\\s|$)"); n = n.replace(o, "$1" + t + "js$2") } Modernizr._config.enableClasses && (n += " " + t + e.join(" " + t), w ? b.className.baseVal = n : b.className = n) } function i() { return "function" != typeof n.createElement ? n.createElement(arguments[0]) : w ? n.createElementNS.call(n, "http://www.w3.org/2000/svg", arguments[0]) : n.createElement.apply(n, arguments) } function a() { var e = n.body; return e || (e = i(w ? "svg" : "body"), e.fake = !0), e } function l(e, t, o, r) { var s, l, f, u, c = "modernizr", d = i("div"), p = a(); if (parseInt(o, 10)) for (; o--; ) f = i("div"), f.id = r ? r[o] : c + (o + 1), d.appendChild(f); return s = i("style"), s.type = "text/css", s.id = "s" + c, (p.fake ? p : d).appendChild(s), p.appendChild(d), s.styleSheet ? s.styleSheet.cssText = e : s.appendChild(n.createTextNode(e)), d.id = c, p.fake && (p.style.background = "", p.style.overflow = "hidden", u = b.style.overflow, b.style.overflow = "hidden", b.appendChild(p)), l = t(d, e), p.fake ? (p.parentNode.removeChild(p), b.style.overflow = u, b.offsetHeight) : d.parentNode.removeChild(d), !!l } function f(e, n) { return !! ~("" + e).indexOf(n) } function u(e) { return e.replace(/([a-z])-([a-z])/g, function (e, n, t) { return n + t.toUpperCase() }).replace(/^-/, "") } function c(e, n) { return function () { return e.apply(n, arguments) } } function d(e, n, t) { var r; for (var s in e) if (e[s] in n) return t === !1 ? e[s] : (r = n[e[s]], o(r, "function") ? c(r, t || n) : r); return !1 } function p(e) { return e.replace(/([A-Z])/g, function (e, n) { return "-" + n.toLowerCase() }).replace(/^ms-/, "-ms-") } function m(n, o) { var r = n.length; if ("CSS" in e && "supports" in e.CSS) { for (; r--; ) if (e.CSS.supports(p(n[r]), o)) return !0; return !1 } if ("CSSSupportsRule" in e) { for (var s = []; r--; ) s.push("(" + p(n[r]) + ":" + o + ")"); return s = s.join(" or "), l("@supports (" + s + ") { #modernizr { position: absolute; } }", function (e) { return "absolute" == getComputedStyle(e, null).position }) } return t } function h(e, n, r, s) { function a() { c && (delete E.style, delete E.modElem) } if (s = o(s, "undefined") ? !1 : s, !o(r, "undefined")) { var l = m(e, r); if (!o(l, "undefined")) return l } for (var c, d, p, h, v, y = ["modernizr", "tspan"]; !E.style; ) c = !0, E.modElem = i(y.shift()), E.style = E.modElem.style; for (p = e.length, d = 0; p > d; d++) if (h = e[d], v = E.style[h], f(h, "-") && (h = u(h)), E.style[h] !== t) { if (s || o(r, "undefined")) return a(), "pfx" == n ? h : !0; try { E.style[h] = r } catch (g) { } if (E.style[h] != v) return a(), "pfx" == n ? h : !0 } return a(), !1 } function v(e, n, t, r, s) { var i = e.charAt(0).toUpperCase() + e.slice(1), a = (e + " " + k.join(i + " ") + i).split(" "); return o(n, "string") || o(n, "undefined") ? h(a, n, r, s) : (a = (e + " " + z.join(i + " ") + i).split(" "), d(a, n, t)) } function y(e, n, o) { return v(e, t, t, n, o) } var g = [], x = [], C = { _version: "3.3.1", _config: { classPrefix: "", enableClasses: !0, enableJSClass: !0, usePrefixes: !0 }, _q: [], on: function (e, n) { var t = this; setTimeout(function () { n(t[e]) }, 0) }, addTest: function (e, n, t) { x.push({ name: e, fn: n, options: t }) }, addAsyncTest: function (e) { x.push({ name: null, fn: e }) } }, Modernizr = function () { }; Modernizr.prototype = C, Modernizr = new Modernizr; var b = n.documentElement, w = "svg" === b.nodeName.toLowerCase(), _ = C._config.usePrefixes ? " -webkit- -moz- -o- -ms- ".split(" ") : ["", ""]; C._prefixes = _; var S = C.testStyles = l; Modernizr.addTest("touchevents", function () { var t; if ("ontouchstart" in e || e.DocumentTouch && n instanceof DocumentTouch) t = !0; else { var o = ["@media (", _.join("touch-enabled),("), "heartz", ")", "{#modernizr{top:9px;position:absolute}}"].join(""); S(o, function (e) { t = 9 === e.offsetTop }) } return t }); var T = "Moz O ms Webkit", k = C._config.usePrefixes ? T.split(" ") : []; C._cssomPrefixes = k; var z = C._config.usePrefixes ? T.toLowerCase().split(" ") : []; C._domPrefixes = z; var P = { elem: i("modernizr") }; Modernizr._q.push(function () { delete P.elem }); var E = { style: P.elem.style }; Modernizr._q.unshift(function () { delete E.style }), C.testAllProps = v, C.testAllProps = y, function () { Modernizr.addTest("csscolumns", function () { var e = !1, n = y("columnCount"); try { (e = !!n) && (e = new Boolean(e)) } catch (t) { } return e }); for (var e, n, t = ["Width", "Span", "Fill", "Gap", "Rule", "RuleColor", "RuleStyle", "RuleWidth", "BreakBefore", "BreakAfter", "BreakInside"], o = 0; o < t.length; o++) e = t[o].toLowerCase(), n = y("column" + t[o]), ("breakbefore" === e || "breakafter" === e || "breakinside" == e) && (n = n || y(t[o])), Modernizr.addTest("csscolumns." + e, n) } (), Modernizr.addTest("flexbox", y("flexBasis", "1px", !0)), Modernizr.addTest("flexboxlegacy", y("boxDirection", "reverse", !0)), Modernizr.addTest("flexboxtweener", y("flexAlign", "end", !0)), r(), s(g), delete C.addTest, delete C.addAsyncTest; for (var j = 0; j < Modernizr._q.length; j++) Modernizr._q[j](); e.Modernizr = Modernizr } (window, document); 831 832var touchScreen = $('html').hasClass('touchevents'); 833var iDevice = navigator.userAgent.match(/(iPad|iPhone|iPod)/g);
834var webKit = navigator.userAgent.match(/(AppleWebKit)/g); 835 836function productLayout() { 837 if (breakpointSM) { $('#ProductHeadingNarrow >*').appendTo('#ProductHeadingNotNarrow'); } 838 else { $('#ProductHeadingNotNarrow >*').appendTo('#ProductHeadingNarrow'); } 839} 840 841function checkWishStatus() { 842 wstat = $('span[id^="ui-product-"]').is("[data-moodboard]"); 843 if (wstat == true) { 844 $('span[data-moodboard="true"]').prev('span').removeClass('fa-star').addClass('fa-check'); 845 $('span[data-moodboard="true"]').html('ADDED TO WISHLIST'); 846 } else { 847 $('span[data-moodboard="false"]').prev('span').removeClass('fa-check').addClass('fa-star'); 848 $('span[data-moodboard="false"]').html('ADD TO WISHLIST'); 849 } 850} 851 852var banners; 853function promoBanner(fadeInterval, fadeDuration) { 854 banners = $('#promobanner>div'); 855 if (typeof promoBannerInterval != 'undefined') clearInterval(promoBannerInterval); 856 857 var numberOfBannersToShow; 858 if (!breakpointMS) { numberOfBannersToShow = 1; } 859 else if (!breakpointSM) { numberOfBannersToShow = 2; } 860 else if (!breakpointMD) { numberOfBannersToShow = 2 /*3*/; } 861 else { numberOfBannersToShow = 4; } 862 863 banners.stop(true, true).removeClass().addClass('f-brand-persist-descendents slice-size-' + numberOfBannersToShow).hide(); 864 banners.slice(0, numberOfBannersToShow).show(); 865 if (numberOfBannersToShow < banners.length) promoBannerInterval = setInterval(function () { promoBannerChange(numberOfBannersToShow, fadeDuration); }, fadeInterval); 866} 867 868function promoBannerChange(sliceSize, fadeDuration) { 869 var bannerCurrent = banners.filter(':visible'); 870 var bannerNextIndex = (bannerCurrent.index() + sliceSize >= banners.length) ? 0 : bannerCurrent.index() + sliceSize; 871 var bannerNext = banners.slice(bannerNextIndex, bannerNextIndex + sliceSize); 872 bannerCurrent.fadeOut(fadeDuration); 873 bannerNext.fadeIn(fadeDuration); 874} 875 876//PRODUCT PAGE INTERNAL NAV 877$(document).on('click', '[data-scrollspy]', function () { 878 var linktoID = $(this).attr('data-scrollspy'); 879 var scrollPoint = $('#' + linktoID).offset().top - heightHeaderTotal; 880 if ($('#ProductInternalNav').nextAll('#' + linktoID).length == 1) scrollPoint = scrollPoint - $('#ProductInternalNav').height(); 881 $('html, body').animate({ scrollTop: scrollPoint }, 200); 882}); 883 884function eliteScrollSpy() { 885 if ($('#ProductInternalNav').length == 1) { 886 heightInternalNav = $('#ProductInternalNav').outerHeight(); 887 spyLinks = []; 888 spyOffsets = []; 889 countSpy = $('[data-scrollspy]').length; 890 $('[data-scrollspy]').each(function () { 891 spyLinks.push($(this)); 892 spyOffsets.push($('#' + $(this).data('scrollspy')).offset().top); 893 }); 894 895 $(window).on('scroll', function () { 896 var currentScrollTop = $(window).scrollTop() + windowHeight / 2; 897 for (var k = 0; k < countSpy; k++) if (currentScrollTop > spyOffsets[k]) spyLinks[k].addClass('f-brand').siblings().removeClass('f-brand'); 898 }); 899 } 900} 901 902function loadVisible($els, trigger) { 903 $els.filter(function () { 904 var rect = this.getBoundingClientRect(); 905 return rect.top >= 0 && rect.top <= window.innerHeight; 906 }).trigger(trigger); 907} 908 909function positionCookieBar() { 910 //#908953 911 if ($('[data-staticfooter="2"]').length == 0) { 912 if ( breakpointSM && $('footer #cookiebar').length == 0) $('#cookiebar').prependTo($('footer')); 913 if (!breakpointSM && $('header #cookiebar').length == 0) $('#cookiebar').prependTo($('header')); 914 } else { 915 if (breakpointSM && $('#cookieSMwrapper #cookiebar').length == 0) $('#cookiebar').appendTo($('#cookieSMwrapper')); 916 if (!breakpointSM && $('header #cookiebar').length == 0) $('#cookiebar').prependTo($('header')); 917} 918} 919 920function ToggleDiv(target) { 921 $('#' + target).slideToggle(); 922} 923 924function dsScrollBottom() { 925 if (breakpointSM) $('html, body').animate({ scrollTop: $(document).height() }, animationDuration); 926} 927 928var mobileMenuWidth = 268; 929$(document).ready(function () { cssTransitionDuration = parseFloat($('#nav-wrapper').css('transition-duration')) * 1000; }); 930 931/************ MEGAMENU FOR MOBILE ************/ 932//#750324 933$(document).on('click', '.slidingmenu-open', function () { 934 loadOrShowMenu(); 935 hideAllDropdownsExcept('menu'); 936 $('body').addClass('slidingmenu'); 937 $('.slidingmenu-close,#overlay-sitebody').fadeIn(); 938 if ($('html').hasClass('alternative-onepage')) clearInterval(altPageInterval); //#748566 939 if ($('html').hasClass('fullpage')) $('html').css('overflow', 'auto'); //#759501 940 initStickiness(); 941}); 942$(document).on('click', '.slidingmenu-close,#overlay-sitebody', function () { 943 scroll(0, 0); 944 $('#header-main').removeClass('sticky-when-reached'); //#891191 layering issue 945 $('body').removeClass('slidingmenu'); 946 $('.slidingmenu-close,#overlay-sitebody').fadeOut(function () { 947 if ($('html').hasClass('alternative-onepage')) initAltPageInterval(); //#748566 948 if ($('html').hasClass('fullpage')) $('html').css('overflow', 'hidden'); //#759501 949 $('#header-main').addClass('sticky-when-reached'); //#891191 layering issue 950 initStickiness(); 951 });
952}); 953 954//#741050 START 955$(document).on('click', '#nav-level0 .haschildren', function (e) { 956 if (!breakpointSM || menuLayout == 'sliding') { 957 e.preventDefault(); //don't link to cat 958 if (typeof navBackTimeout != 'undefined') clearTimeout(navBackTimeout); //don't complete sub-cat hiding 959 $('#nav-level1 [data-parent0="' + $(this).data('code') + '"]').removeClass('hidden'); //show relevant sub-cats 960 $('#nav-wrapper').addClass('moved'); //slide left 961 scroll(0, 0); //jump to top 962 } 963}); 964 965$(document).on('click', '#nav-level1 .haschildren', function (e) { 966 if (!breakpointSM || menuLayout == 'sliding') { 967 e.preventDefault(); //don't link to cat 968 if (typeof navBackTimeout != 'undefined') clearTimeout(navBackTimeout); //don't complete sub-cat hiding 969 $('#nav-level2 [data-parent1="' + $(this).data('code') + '"]').removeClass('hidden').parent().removeClass('hidden'); //show relevant sub-cats 970 $('#nav-wrapper').addClass('moved-twice'); //slide left 971 scroll(0, 0); //jump to top 972 } 973}); 974 975$(document).on('click', '.nav-back', function () { 976 if ($('#nav-wrapper').hasClass('moved-twice')) { 977 $('#nav-wrapper').removeClass('moved-twice'); //slide from level 2 to level 1 978 navBackTimeout = setTimeout(function () { $('#nav-level2 [data-parent0], #nav-level2 [data-parent1]').addClass('hidden'); }, cssTransitionDuration); //hide sub-cats after sliding complete 979 } else { 980 $('#nav-wrapper').removeClass('moved'); //slide from level 1 to level 0 981 navBackTimeout = setTimeout(function () { $('#nav-level1 [data-parent0]').addClass('hidden'); }, cssTransitionDuration); //hide sub-cats after sliding complete 982 }; 983}); 984 985if (menuLayout == 'dropdown') { 986 /************ MEGAMENU FOR TOUCHSCREEN LARGER THAN MOBILE ************/ 987 //1st tap opens megamenu, 2nd tap closes it 988 $(document).on('touchend', '#nav-level0 [data-code]', function (e) { 989 if (breakpointSM && menuLayout == 'dropdown') { 990 e.preventDefault(); 991 var m = $(this); 992 if (m.hasClass('current')) { menuTimeout = setTimeout(function () { hideMenu(animationDuration); }, animationDuration) } else { loadOrShowMenu(m); } 993 } 994 }); 995 //#908953 START 996 $(document).on('touchend', '.level0-sm [data-code]', function (e) { 997 if (breakpointSM && menuLayout == 'dropdown') { 998 e.preventDefault(); 999 var m = $(this); 1000 showSubMenu(m); 1001 } 1002 }); 1003 //#908953 END 1004 1005 /************ MEGAMENU FOR MOUSE ************/ 1006 $(document).on('mouseenter', '#nav-level0 [data-code]', function () { 1007 if (breakpointSM) { var m = $(this); timerDropdownShow = setTimeout(function () { loadOrShowMenu(m); }, delayDropdownShow); } 1008 }); 1009 $(document).on('mouseleave', '#nav-level0 [data-code]', function () { 1010 if (breakpointSM) { if (typeof timerDropdownShow != 'undefined') { clearTimeout(timerDropdownShow); } } 1011 }); 1012 $(document).on('mouseenter', '#nav-level0 [data-code], #nav-level2', function () { 1013 if (breakpointSM) { if (typeof timerDropdownHide != 'undefined') { clearTimeout(timerDropdownHide); } } 1014 }); 1015 $(document).on('mouseleave', '#nav-level0 [data-code], #nav-level2', function () { 1016 if (breakpointSM) { timerDropdownHide = setTimeout(function () { hideMenu(0); }, delayDropdownHide); } 1017 }); 1018 //#908953 START 1019 $(document).on('mouseenter', '.level0-sm [data-code]', function () { 1020 if (breakpointSM) { var m = $(this); timerSubmenuShow = setTimeout(function () { showSubMenu(m); }, delaySubmenuShow); } 1021 }); 1022 $(document).on('mouseleave', '.level0-sm [data-code]', function () { 1023 if (breakpointSM) { if (typeof timerSubmenuShow != 'undefined') { clearTimeout(timerSubmenuShow); } } 1024 }); 1025 //#908953 END 1026} 1027 1028 1029$(function () { 1030 let focusedByTab = false; 1031 1032 $(document).on('keydown', function (e) { 1033 if (e.key === 'Tab') { 1034 focusedByTab = true; 1035 } 1036 }); 1037 1038 $(document).on('mousedown touchstart', function () { 1039 focusedByTab = false; 1040 }); 1041 1042 // TAB → focus IN 1043 $('#nq-searchINPUT').on('focus', function () { 1044 if (focusedByTab) { 1045 hideSearchDropdown(0); 1046 $('#nq-predictive-search').hide(0); 1047 } 1048 }); 1049 1050 // TAB → focus OUT 1051 $('#nq-searchINPUT').on('focusout', function () { 1052 if (focusedByTab) { 1053 showSearchDropdown(0); 1054 $('#nq-predictive-search').show(0); 1055 } 1056 1057 // reset AFTER focus traversal completes 1058 setTimeout(function () { 1059 focusedByTab = false; 1060 }, 0); 1061 }); 1062 1063 1064 $(document).on('keydown', '.slidingsearch-open', function (e) { 1065 if (e.key === 'Enter' || e.key === ' ') { 1066 e.preventDefault(); 1067 $(this).trigger('click'); 1068 } 1069 });
1070 1071}); 1072 1073 1074 1075 1076//#1184287 1077function getFocusableLinks($container) { 1078 return $container.find('a') 1079 .filter(':visible') 1080 .not('.nav-back') 1081 .not('[tabindex="-1"]'); 1082} 1083 1084// Keyboard support for level 0 navigation 1085$(document).on('keydown', '#nav-level0 [data-code]', function (e) { 1086 if (!breakpointSM) return; 1087 1088 var $item = $(this); 1089 var code = $item.data('code'); 1090 1091 // ENTER or SPACE → open dropdown 1092 if (e.key === 'Enter' || e.key === ' ') { 1093 e.preventDefault(); 1094 1095 if (typeof timerDropdownHide !== 'undefined') { 1096 clearTimeout(timerDropdownHide); 1097 } 1098 1099 // Open menu (same as hover) 1100 loadOrShowMenu($item); 1101 1102 // Wait for the correct panel to become visible 1103 var attempts = 0; 1104 var maxAttempts = 10; 1105 1106 var interval = setInterval(function () { 1107 attempts++; 1108 1109 var $panel = $('#nav-level2 [data-parent0="' + code + '"]:visible'); 1110 1111 if ($panel.length) { 1112 var $links = getFocusableLinks($panel); 1113 1114 if ($links.length) { 1115 clearInterval(interval); 1116 $links.first().focus(); 1117 } 1118 } 1119 1120 if (attempts >= maxAttempts) { 1121 clearInterval(interval); 1122 // fallback: keep focus on level 0 item 1123 $item.focus(); 1124 } 1125 }, 50); 1126 } 1127 1128 // ESC → close menu and restore focus 1129 if (e.key === 'Escape') { 1130 hideMenu(0); 1131 $item.focus(); 1132 } 1133}); 1134 1135 1136$(document).on('keydown', '#nav-level2 a', function (e) { 1137 var $panel = $(this).closest('[data-parent0]'); 1138 if (!$panel.length) return; 1139 1140 var $links = getFocusableLinks($panel); 1141 var index = $links.index(this); 1142 1143 if (index === -1) return; 1144 1145 switch (e.key) { 1146 case 'ArrowDown': 1147 e.preventDefault(); 1148 $links.eq((index + 1) % $links.length).focus(); 1149 break; 1150 1151 case 'ArrowUp': 1152 e.preventDefault(); 1153 $links.eq((index - 1 + $links.length) % $links.length).focus(); 1154 break; 1155 1156 case 'Escape': 1157 e.preventDefault(); 1158 hideMenu(0); 1159 $('#nav-level0 [data-code="' + $panel.data('parent0') + '"]').focus(); 1160 break; 1161 } 1162}); 1163 1164 1165 1166 1167 1168 1169/************ MEGAMENU UTILITY FUNCTIONS ************/ 1170function showMenu(m) { 1171 if (menuLayout == 'dropdown') { 1172 //hide all other dropdowns 1173 hideAllDropdownsExcept('menu'); 1174 1175 //don't complete menu hiding 1176 if (typeof timerDropdownHide != 'undefined') { clearTimeout(timerDropdownHide); } 1177 1178 if (!m.hasClass('current')) { //prevent repeat run after scrolling 1179 //prevent stickiness if no menu already showing 1180 if ($('[data-code].current').length == 0) preventStickiness(); 1181 1182 //update current 1183 $('[data-code].current').removeClass('current'); 1184 1185 //populate menu, display dropdown 1186 //#908953 START 1187 $('#nav-level2 [data-parent0]').addClass('hidden').children().addClass('hidden'); //hide all level 2 content 1188 1189 if ($('#nav-level2 [data-parent0="' + m.data('code') + '"]').length == 0) { //no matching items 1190 $('#nav-level2, #overlay-menu').css('display', ''); //hide level 2 and overlay 1191 } else { //matching items 1192 $('#nav-level2 [data-parent0="' + m.data('code') + '"]').removeClass('hidden').children().removeClass('hidden'); //show level 2 content relevant to current level 0 item 1193 $('[data-navtemplate="1"] .hassubsections').eq(0).removeClass('hidden').siblings().addClass('hidden'); //hide all level 1/2 content except items relevant to first level 1 item (template 1) 1194 $('[data-navtemplate="1"] .hassubsections').eq(0).find('.haschildren').eq(0).addClass('current').siblings().removeClass('current'); //set first level 0 that has children as current (template 1) 1195 1196 $('#nav-level2').slideDown(animationDuration); //show level 2 1197 $('#overlay-menu').fadeIn(animationDuration); 1198 m.addClass('current'); 1199 } 1200 //#908953 END 1201 } 1202 } 1203} 1204 1205function hideMenu(duration) { 1206 $('#nav-level2').filter(':visible').stop(true, false).slideUp(duration, function () { $('[data-code].current').removeClass('current'); toggleAllStickiness(); $('#nav-level1, #nav-level2, #overlay-menu').css('display', ''); }); //#908953 1207 $('#overlay-menu').stop(true, false).fadeOut(duration); 1208 $('body').removeClass('showdropdown'); 1209} 1210 1211function preventStickiness() { 1212 $('body').addClass('showdropdown'); //class to override and prevent stickiness 1213 1214 //#908953 START 1215 //Jump to point where stickiness began, if scrolled past it 1216 if ($('#nav-level0').hasClass('fixed')) { 1217 if ($('[data-header="1"]').length == 0) { 1218 scroll(0, $('#header-bar').outerHeight()); 1219 } else { 1220 scroll(0, 36); 1221 } 1222 } else if ($('[data-header="1"]').length == 1 && $('#header-main').hasClass('fixed')) { 1223 1224 } 1225 1226 deactivateElementStickiness($('#header-main'), $('#stickyHeaderMainGap')); //#965710 1227 deactivateElementStickiness($('#nav-level0'), $('#header-nav')); 1228 //#908953 END 1229} 1230 1231function loadOrShowMenu(m) { 1232 if ($('#inav').attr('data-nav') == 'false') { 1233 //first menu load - populate nav 1234 firstMenu = m; 1235 //#908953 1236 if ($('[data-navtemplate="1"]').length == 1) 1237 ajaxGET(siteSubDirectory + '/nav1/?1=1' + generateQueryStrings(), 'inav'); 1238 else
1239 ajaxGET(siteSubDirectory + '/nav/?1=1' + generateQueryStrings(), 'inav'); 1240 $('#inav').attr('data-nav', 'true'); 1241 } else if (typeof m != 'undefined' && breakpointSM) { 1242 //subsequent menu load - tablet/desktop go straight to displaying dropdown 1243 showMenu(m); 1244 } 1245} 1246//#741050 END 1247 1248//#908953 START 1249function showSubMenu(m) { 1250 $('.level0-sm [data-code]').removeClass('current'); 1251 $('.level0-sm [data-code="' + m.data('code') + '"]').addClass('current'); 1252 $('[data-parent1]').addClass('hidden'); 1253 $('[data-parent1="' + m.data('code') + '"]').removeClass('hidden'); 1254} 1255//#908953 END 1256 1257//#947809, #1006441 1258function showHeaderTabsLevel1(m) { 1259 $('#header-tabs-level0 [data-code]').removeClass('header-tabs-current'); 1260 $('#header-tabs-level0 [data-code="' + m + '"]').addClass('header-tabs-current'); 1261 1262 $('#header-tabs-level1 [data-parent0]').addClass('hidden'); 1263 if ($('#header-tabs-level1 [data-parent0="' + m + '"]').length == 1) { 1264 $('#header-tabs-level1 [data-parent0="' + m + '"]').removeClass('hidden'); 1265 } else { 1266 $('.header-tabs-level1-persistent').removeClass('hidden'); 1267 } 1268 $('#header-tabs-level2 [data-parent1]').addClass('hidden'); 1269} 1270 1271function showHeaderTabsLevel2(m) { 1272 $('#header-tabs-level1 [data-code]').removeClass('header-tabs-current'); 1273 $('#header-tabs-level1 [data-code="' + m + '"]').addClass('header-tabs-current'); 1274 1275 $('#header-tabs-level2 [data-parent1]').addClass('hidden'); 1276 if ($('#header-tabs-level2 [data-parent1="' + m + '"] a:not(.nav-heading)').length > 0) { 1277 $('#header-tabs-level2 [data-parent1="' + m + '"]').removeClass('hidden').parent().removeClass('hidden'); 1278 } 1279} 1280 1281function showHeaderTabsPersistentLevel1() { 1282 $('#header-tabs-level0 [data-code]').removeClass('header-tabs-current'); 1283 $('.header-tabs-level0-persistent').addClass('header-tabs-current'); 1284 1285 $('#header-tabs-level1 [data-parent0]').addClass('hidden'); 1286 $('.header-tabs-level1-persistent').removeClass('hidden'); 1287} 1288 1289function showHeaderTabsPersistentLevel2() { 1290 $('#header-tabs-level1 [data-code]').removeClass('header-tabs-current'); 1291 $('.header-tabs-level1-persistent').addClass('header-tabs-current'); 1292 1293 $('#header-tabs-level2 [data-parent1]').addClass('hidden'); 1294 $('.header-tabs-level2-persistent').removeClass('hidden').parent().removeClass('hidden'); 1295} 1296 1297$(document).on('click', '#header-tabs-level0 a:not(.header-tabs-current)', function (e) { 1298 e.preventDefault(); 1299 showHeaderTabsLevel1($(this).data('code')); 1300}); 1301 1302$(document).on('click', '#header-tabs-level1 a:not(.header-tabs-current)', function (e) { 1303 e.preventDefault(); 1304 showHeaderTabsLevel2($(this).data('code')); 1305}); 1306 1307$(document).on('mouseenter', '#header-tabs-level0 a', function () { 1308 if (breakpointSM) { var m = $(this); timerDropdownShow1 = setTimeout(function () { showHeaderTabsLevel1(m.data('code')); }, delayDropdownShow); } 1309}); 1310$(document).on('mouseleave', '#header-tabs-level0 a', function () { 1311 if (breakpointSM) { if (typeof timerDropdownShow1 != 'undefined') { clearTimeout(timerDropdownShow1); } } 1312}); 1313$(document).on('mouseenter', '#header-tabs-level0 a, #header-tabs-level1, #header-tabs-level2', function () { 1314 if (breakpointSM) { if (typeof timerDropdownHide1 != 'undefined') { clearTimeout(timerDropdownHide1); } } 1315}); 1316$(document).on('mouseleave', '#header-tabs-level0 a, #header-tabs-level1, #header-tabs-level2', function () { 1317 if (breakpointSM) { timerDropdownHide1 = setTimeout(function () { showHeaderTabsPersistentLevel1(); showHeaderTabsPersistentLevel2(); }, delayDropdownHide); } 1318}); 1319$(document).on('mouseenter', '#header-tabs-level1 a', function () { 1320 if (breakpointSM) { var m = $(this); timerDropdownShow2 = setTimeout(function () { showHeaderTabsLevel2(m.data('code')); }, delayDropdownShow); } 1321}); 1322$(document).on('mouseleave', '#header-tabs-level1 a', function () { 1323 if (breakpointSM) { if (typeof timerDropdownShow2 != 'undefined') { clearTimeout(timerDropdownShow2); } } 1324}); 1325$(document).on('mouseenter', '#header-tabs-level1 a, #header-tabs-level2', function () { 1326 if (breakpointSM) { if (typeof timerDropdownHide2 != 'undefined') { clearTimeout(timerDropdownHide2); } } 1327}); 1328$(document).on('mouseleave', '#header-tabs-level1 a, #header-tabs-level2', function () { 1329 if (breakpointSM) { timerDropdownHide2 = setTimeout(function () { showHeaderTabsPersistentLevel2(); }, delayDropdownHide); } 1330}); 1331 1332//#707331 1333function productZoom() { 1334 if (breakpointMD && $('#mainImage').length > 0) { 1335 $('#zoomArea').jqzoom({ zoomType: 'standard', lens: true, preloadImages: false, alwaysOn: false }); 1336 $('.zoomPup').removeClass('hidden'); 1337 } else { 1338 $('#zoomArea').unbind('mouseover'); 1339 $('.zoomPup').addClass('hidden'); 1340 } 1341} 1342 1343function copyemailaddress(ors, cpt) { 1344 if($('#'+ors).val() != ''){ 1345 if(isValidEmailAddress($('#'+ors).val()) ) { 1346 $('#'+cpt).val($('#'+ors).val()) 1347 }; 1348 }; 1349} 1350 1351function isValidEmailAddress(emailAddress) { 1352 var pattern = /^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([ \t]*\r\n)?[ \t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i; 1353 return pattern.test(emailAddress); 1354}; 1355 1356function registrationopt(target, container) { 1357 if($('#'+target).is(':checked')){ 1358 $('#'+container).slideDown(); 1359 } else { 1360 $('#'+container).slideUp(); 1361 $('#'+container +' input#login_password').val('') 1362 $('#'+container +' input#login_password2').val('') 1363 } 1364} 1365 1366function getMyHTMLElement(id) { return document.getElementById(id); } 1367 1368//STRING FUNCTIONS -- START 1369function replaceString(aSearch, aFind, aReplace) { 1370 result = aSearch; 1371 if (result != null && result.length > 0) { 1372 a = 0; 1373 b = 0; 1374 while (true) { 1375 a = result.indexOf(aFind, b); 1376 if (a != -1) { 1377 result = result.substring(0, a) + aReplace + result.substring(a + aFind.length); 1378 b = a + aReplace.length; 1379 } 1380 else 1381 break; 1382 } 1383 } 1384 return result; 1385} 1386 1387function strLeft(str, n) { 1388 if (n <= 0) 1389 return ""; 1390 else if (n > String(str).length) 1391 return str; 1392 else 1393 return String(str).substring(0, n); 1394} 1395 1396function strRight(str, n) { 1397 if (n <= 0) 1398 return ""; 1399 else if (n > String(str).length) 1400 return str; 1401 else { 1402 var iLen = String(str).length; 1403 return String(str).substring(iLen, iLen - n); 1404 } 1405} 1406 1407function trim(str) { 1408 if (!str || typeof str != 'string') return null; 1409 return str.replace(/^\s+|\s+$/, ''); 1410} 1411//STRING FUNCTIONS -- END 1412 1413function changeQty(objName, mathematics) { 1414 var place = $('form[name="basketform"] #' + objName)[0]; 1415 place.value = parseInt(place.value) + parseInt(mathematics); 1416 if (isNaN(place.value)) place.value = 1; 1417 if (place.value < 0) place.value = 0; 1418 //#864139 START 1419 var action1; var action2; var divID; 1420 divID = objName.split("_"); 1421 if (mathematics == 1) { 1422 action1 = 'addToCart'; 1423 action2 = 'add'; 1424 } else { 1425 action1 = 'removeFromCart'; 1426 action2 = 'remove'; 1427 } 1428 TriggerGTMBasketProducts(divID[1], action1, action2, 1); 1429 //#864139 END 1430 document.basketform.submit(); 1431} 1432 1433//#864139 START 1434function BasketUpdateQty(index, qtyInput) { 1435 var action1; var action2; var qty; var previousQty; 1436 previousQty = parseInt($('#gtm' + index).data('pqty'));
1437 if (isNaN(qtyInput)) { qtyInput = 1; } 1438 if (qtyInput != previousQty) { 1439 if (previousQty > qtyInput) { 1440 action1 = 'removeFromCart'; 1441 action2 = 'remove'; 1442 qty = previousQty - qtyInput; 1443 } else { 1444 action1 = 'addToCart'; 1445 action2 = 'add'; 1446 qty = qtyInput - previousQty; 1447 } 1448 TriggerGTMBasketProducts(index, action1, action2, qty); 1449 } 1450 document.basketform.submit(); 1451} 1452 1453function basket_saveitem(basket_id, index, save_for_later) { 1454 //#864139 START 1455 var action1; var action2; var qty; 1456 if (save_for_later == 1) { 1457 action1 = 'removeFromCart'; 1458 action2 = 'remove'; 1459 qty = $('form[name="basketform"] #qty_' + index)[0].value; 1460 } else { 1461 action1 = 'addToCart'; 1462 action2 = 'add'; 1463 qty = $('#gtmSaverForLater' + index).data('pqty'); 1464 index = 'SaverForLater' + index; 1465 } 1466 TriggerGTMBasketProducts(index, action1, action2, qty); 1467 //#864139 END 1468} 1469//#864139 END 1470 1471function ajaxEmailAFriendBack() { 1472 if (previousContentEmail != '') { 1473 getMyHTMLElement('emailAfriendTEXT').innerHTML = previousContentEmail 1474 } 1475} 1476 1477function showCookieInfo() { 1478 $(document).ready(function () { 1479 $('#cookieContent').slideToggle('slow', function () { 1480 if ($(this).css("display") == "block") $('#morelink').css('background-image', 'url(../images/core/cookie-arrow-down.png)'); 1481 else $('#morelink').css('background-image', 'url(../images/core/cookie-arrow-right.png)'); 1482 }); 1483 }); 1484} 1485 1486function swapImage(id, src) { 1487 if (src != '') { getMyHTMLElement(id).src = src; } 1488} 1489 1490function copyBillingAdd(bFlag) { 1491 if (bFlag == 'true') { 1492 setField("firstname"); setField("surname"); setField("title"); setField("Country"); 1493 setField("address1"); setField("address2"); setField("address4"); setField("address5"); 1494 } 1495 else { 1496 setField("firstname"); setField("surname"); setField("title"); setField("Country"); 1497 resetField("address1"); resetField("address2"); resetField("address4"); resetField("address5"); 1498 } 1499 1500} 1501 1502function setField(sField) { 1503 if (sField == "firstname" || sField == "surname") { 1504 document.getElementById('del_' + sField).value = document.getElementById(sField).value; 1505 } 1506 else { 1507 document.getElementById('del_' + sField).value = document.getElementById(sField).value; 1508 } 1509} 1510 1511function resetField(sField) { 1512 if (sField == "Country") { 1513 document.getElementById('del_' + sField).selectedIndex = 0; 1514 } 1515 else { 1516 document.getElementById('del_' + sField).value = ''; 1517 } 1518} 1519 1520/*#538412*/ 1521function is_email(email) { 1522 var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 1523 return emailReg.test(email); 1524} 1525 1526function checkFormField(id, rule, min, max) { 1527 if (min == undefined) { min = 1 } 1528 if (max == undefined) { max = 35 } 1529 var inputGrading = "inputPASS" 1530 switch (rule) { 1531 case "email": 1532 if (is_email($('#' + id).val()) == false) {/*#538412*/ 1533 inputGrading = "inputFAIL" 1534 } 1535 break; 1536 case "text": 1537 if (min > 0 && getMyHTMLElement(id).value.length < min) { inputGrading = "inputFAIL" } 1538 if (getMyHTMLElement(id).value.length > max) { inputGrading = "inputFAIL" } 1539 break; //#664306 1540 case "postcode": 1541 //#664306 - START 1542 if (min > 0 && getMyHTMLElement(id).value.length < min) { inputGrading = "inputFAIL" } 1543 if (getMyHTMLElement(id).value.length > max) { inputGrading = "inputFAIL" } 1544 break; 1545 //#664306 - END 1546 case "phone": 1547 if (min > 0 && getMyHTMLElement(id).value.length < min) { inputGrading = "inputFAIL" } 1548 if (getMyHTMLElement(id).value.length > max) { inputGrading = "inputFAIL" } 1549 break; //#664306 1550 default: 1551 break; 1552 } 1553 $('#' + id).attr('data-validation', inputGrading); 1554} 1555 1556function isValueValid(value) { 1557 var returnValue = true 1558 if (value == null || value == 'undefined' || value == '') { returnValue = false; } 1559 return returnValue; 1560} 1561 1562function showhidebasket(listdiv, indicator, desclabel) { 1563 $('#' + listdiv).slideToggle(function () { 1564 if ($(this).is(':visible')) { 1565 $('.' + indicator).removeClass('fa-plus').addClass('fa-minus'); 1566 $('.' + desclabel).text('click to close / see less') 1567 } else { 1568 $('.' + indicator).removeClass('fa-minus').addClass('fa-plus'); 1569 $('.' + desclabel).text('click to open / see more') 1570 } 1571 });
1572} 1573 1574function page_action(key_name, key_value) { 1575 var current_url = window.location.href; 1576 var current_path = window.location.pathname; 1577 var url_array = current_url.split("?"); 1578 var querystring = ""; 1579 var final_url = ""; 1580 if (url_array.length >= 2) querystring = url_array[1]; 1581 final_url = current_path + "?" + reduceurl_string(querystring, key_name, key_value); 1582 window.location.href = final_url; 1583} 1584 1585function reduceurl_string(queryString, key_name, key_value) { 1586 var queries, temp, i, l; 1587 var return_qs = ""; 1588 // Split into key/value pairs 1589 if (queryString != '' && queryString != null) { 1590 queries = queryString.split("&"); 1591 1592 // Convert the array of strings into an object 1593 for (i = 0, l = queries.length; i < l; i++) { 1594 temp = queries[i].split('='); 1595 if (key_name != temp[0]) { 1596 if (return_qs != null && return_qs != '') { return_qs = return_qs + "&" + temp[0] + "=" + temp[1]; } 1597 else { return_qs = temp[0] + "=" + temp[1]; } 1598 } 1599 } 1600 } 1601 if (key_name != '' && key_value != '') { 1602 if (return_qs != '') { return_qs = return_qs + "&" + key_name + "=" + key_value; } 1603 else { return_qs = key_name + "=" + key_value; } 1604 1605 } 1606 return return_qs; 1607}; 1608 1609//ONEPAGE / ALTERNATIVE ONEPAGE / FULLPAGE //#748566, #759501 1610function loadHomepageLayout() { 1611 if ($('html').hasClass('onepage')) { 1612 loadOnepage(); 1613 } else if ($('html').hasClass('alternative-onepage')) { 1614 loadAlternativeOnepage(); 1615 } else if ($('html').hasClass('fullpage')) { 1616 loadFullpage(); 1617 } 1618} 1619 1620//#750324 1621function resizeHomepage() { 1622 if ($('html').hasClass('onepage') && !$('html').hasClass('ie9') && breakpointSM) { 1623 if (window.RT) clearTimeout(window.RT); 1624 window.RT = setTimeout(function () { this.location.reload(); }, 250); 1625 } else if ($('html').hasClass('alternative-onepage')) { 1626 resizeAlternativeOnepage(); 1627 } else if ($('html').hasClass('fullpage')) { 1628 $.fn.fullpage.destroy('all'); 1629 loadFullpage(); 1630 } 1631} 1632 1633function setPageColor() { 1634 if ($('section.active .onepage-overlay.f-color0').length == 1) { 1635 $('body').addClass('page-color0').removeClass('page-color1').removeClass('page-color6'); 1636 } else if ($('section.active .onepage-overlay.f-color6').length == 1) { 1637 $('body').addClass('page-color6').removeClass('page-color0').removeClass('page-color1'); 1638 } else { 1639 $('body').addClass('page-color1').removeClass('page-color0').removeClass('page-color6'); 1640 } 1641} 1642 1643function toggleButtons() { 1644 //#871139 1645 if ($('section.active:last-child:not(only-child)').length == 1) $('.onepage-next').removeClass('hideonnarrow').addClass('hidden'); //#965710 1646 else $('.onepage-next').removeClass('hidden').addClass('hideonnarrow'); 1647} 1648 1649var video; 1650function checkVideo() { 1651 if ($('section.active .video-placeholder').length == 1 && breakpointSM) { 1652 video = $('<video src="' + $('section.active .video-placeholder').data('videosrc') + '" poster="' + $('section.active .video-placeholder').data('src-large') + '" class="onepage-background" loop="true" playsinline="true" muted="true"></video>')[0]; 1653 $('section.active .video-placeholder').replaceWith(video);
1654 video.play(); 1655 } else if ($('section.active video').length == 1 && breakpointSM) { 1656 video.play(); 1657 } else if (video) { 1658 video.pause(); 1659 } 1660} 1661 1662function homepagePagination() { 1663 if ($('ul.onepage-pagination').length == 0) { 1664 $('#sitebody').append('<ul class="onepage-pagination"></ul>'); 1665 var altPag = $('ul.onepage-pagination'); 1666 var allSections = $('section'); 1667 if ($('html').hasClass('alternative-onepage')) { 1668 for (var i = 0; i < allSections.length; i++) altPag.append('<li><a>' + allSections.eq(i).data('pagination-text') + '</a></li>'); 1669 altPag.find('a').click(function () { 1670 var targetSection = allSections.eq($(this).parent().index()); 1671 $('html,body').animate({ scrollTop: targetSection.offset().top }, animationDuration); 1672 }); 1673 } else if ($('html').hasClass('fullpage')) { 1674 altPag.append('<li><a onclick="$.fn.fullpage.moveTo(1);" class="active"></a><span>' + allSections.eq(0).data('pagination-text') + '</span></li>'); //special case i=0 1675 for (var i = 1; i < allSections.length; i++) altPag.append('<li><a onclick="$.fn.fullpage.moveTo(' + (i + 1) + ');"></a><span>' + allSections.eq(i).data('pagination-text') + '</span></li>'); 1676 } 1677 } 1678} 1679 1680function loadOnepage() { 1681 if (breakpointSM) { 1682 //Tablet/desktop: remove mobile footer slide, initialise with loop, move pagination, play video 1683 $('section:last-child:not(:only-child)').remove(); //#965710 1684 $('.main').onepage_scroll_paraspar({ loop: true, beforeMove: function () { checkVideo(); imagesBelowFold(0); }, afterMove: function () { setPageColor(); } }); 1685 $('body > .onepage-pagination').appendTo('#sitebody'); 1686 } else { 1687 //Mobile: initialise without loop 1688 onepageCurrent = 1; //Used in footer link location: footer close button returns user to current slide 1689 $('.main').onepage_scroll_paraspar({ beforeMove: function (i) { onepageCurrent = i; checkVideo(); imagesBelowFold(0); }, afterMove: function () { setPageColor(); toggleButtons(); imagesBelowFold(0); } }); 1690 } 1691 checkVideo(); 1692 setPageColor(); 1693 1694 $('.onepage-next a').click(function () { $('.onepage-wrapper').moveDown(); }); 1695 $('.onepage-footerlink a').click(function () { $('.onepage-wrapper').moveTo($('.main section').length); }); 1696 $('.onepage-closefooter').click(function () { $('.onepage-wrapper').moveTo(onepageCurrent); }); 1697 $('.onepage-pagination li').click(function () { imagesBelowFold($(this).prev().index() * windowHeight); }); 1698} 1699 1700var visibleSections; 1701var altPageScroll = false; 1702var altPageInterval; 1703function loadAlternativeOnepage() { 1704 visibleSections = $('section').filter(':visible'); 1705 resizeAlternativeOnepage(); 1706 imagesBelowFold(0); 1707 1708 for (var i = 0; i < visibleSections.length; i++) $('section').eq(i).attr('data-index', i); //set data-index for each visible slide 1709 1710 homepagePagination(); 1711 alternativeSetActive(); 1712 1713 $(window).scroll(function () { altPageScroll = true; }); 1714 initAltPageInterval(); 1715 1716 $('.onepage-next a').click(function () { 1717 onepagePrevious = $('section.active'); 1718 var nextSection = $('section.active').next().filter(':visible'); 1719 if (nextSection.length == 0) nextSection = $('section:first-child'); 1720 $('html,body').animate({ scrollTop: nextSection.offset().top }, animationDuration); 1721 }); 1722 1723 $('.onepage-footerlink a').click(function () { 1724 onepagePrevious = $('section.active'); 1725 $('html,body').animate({ scrollTop: $('section:last-child').offset().top }, animationDuration); 1726 }); 1727 1728 $('.onepage-closefooter').click(function () { 1729 if (typeof onepagePrevious == 'undefined') onepagePrevious = $('section:nth-last-child(2)'); 1730 $('html,body').animate({ scrollTop: onepagePrevious.offset().top }, animationDuration); 1731 }); 1732} 1733 1734function initAltPageInterval() { 1735 altPageInterval = setInterval(function () { if (altPageScroll) { altPageScroll = false;
1735 alternativeSetActive(); } }, 200); 1736} 1737 1738var slideChangePoint = 0.5; 1739function alternativeSetActive() { 1740 var newActive = Math.floor(($(document).scrollTop() / windowHeight) + slideChangePoint); //index of slide that should be active 1741 if (newActive != $('section.active').index()) { 1742 $('section').removeClass('active').eq(newActive).addClass('active'); 1743 $('ul.onepage-pagination a').removeClass('active').eq(newActive).addClass('active'); 1744 setPageColor(); 1745 checkVideo(); 1746 if (!breakpointSM) toggleButtons(); 1747 currentWindowHeight = window.innerHeight ? window.innerHeight : $(window).height(); //#748566 1748 if (currentWindowHeight != windowHeight) resizeAlternativeOnepage(); //#748566 1749 } 1750} 1751 1752function resizeAlternativeOnepage() { 1753 windowHeight = window.innerHeight ? window.innerHeight : $(window).height(); //#748566 1754 visibleSections.height(windowHeight); //fit each slide to height of window 1755 $('.main').height(visibleSections.length * windowHeight); //total container height = number of slides * height of window 1756} 1757 1758//#795855 1759function loadFullpage() { 1760 scroll(0, 0); 1761 $('section [data-revealsrc]').each(function () { chooseImage($(this)[0]); $(this).removeAttr('data-revealsrc'); }); 1762 $('section').addClass('section'); 1763 $('section:last-child:not(:only-child)').removeAttr('data-url'); //#799360, #965710 1764 if (breakpointSM) $('section:last-child:not(:only-child)').removeClass('section'); //#965710 1765 else onepageCurrent = 1; 1766 $('.main').fullpage({ 1767 onLeave: function (a, i) { 1768 if (i < $('.main section').length) onepageCurrent = i; 1769 if (typeof autoScrollSlide != 'undefined' && autoScrollSlide != i) disableFullpageAutoScroll(); 1770 }, 1771 afterLoad: function (a, i) { 1772 setPageColor(); 1773 toggleButtons(); 1774 if (i == $('.section').length) $('.onepage-next').removeClass('hideonnarrow').addClass('hidden'); else $('.onepage-next').removeClass('hidden').addClass('hideonnarrow'); //#871139 1775 if (i == $('.section').length - 1 && !breakpointSM) disableFullpageAutoScroll(); 1776 $('ul.onepage-pagination a').removeClass('active').eq(i - 1).addClass('active'); 1777 checkVideo(); 1778 }, 1779 afterRender: function () { enableFullpageAutoScroll(); }, 1780 easingcss3: 'cubic-bezier(0.75, 0.01, 0.75, 0.85)', 1781 loopBottom: false, 1782 normalScrollElements: 'nav,#overlay-sitebody,#dropdown-basket,#overlay-basket' 1783 }); 1784 homepagePagination(); 1785} 1786 1787function enableFullpageAutoScroll() { 1788 disableFullpageAutoScroll(); 1789 1790 var dataScrollInt = $('.fullpage-wrapper').data('scrollinterval'); 1791 if ($.isNumeric(dataScrollInt) && dataScrollInt >= 800) { //FullPage transition + callbacks take 800ms to complete 1792 fpInterval = setInterval(function () { 1793 autoScrollSlide = $('.section.active').index() + 2; //index is 0-based, slide is 1-based 1794 if (autoScrollSlide - 1 == $('.section').length) autoScrollSlide = 1; 1795 $.fn.fullpage.moveTo(autoScrollSlide); 1796 }, dataScrollInt); 1797 } 1798} 1799function disableFullpageAutoScroll() { if (typeof (fpInterval) != 'undefined') { clearInterval(fpInterval); fpInterval = undefined; } } 1800 1801$(document).on('click', '.fullpage .onepage-next a', function () { $.fn.fullpage.moveSectionDown(); }); 1802$(document).on('click', '.fullpage .onepage-footerlink a', function () { $.fn.fullpage.moveTo($('.main section').length); }); 1803$(document).on('click', '.fullpage .onepage-closefooter', function () { $.fn.fullpage.moveTo(onepageCurrent); }); 1804 1805//PERFORMANCE-TUNED IMAGE LOADING -- START 1806var revealScrollOffset = 100; //buffer 1807var didImgScroll = false; 1808var didScroll = false; 1809var maxScrollTop = parseInt(window.pageYOffset); //initial scroll amount 1810 1811//timer for better performance than scroll event handler (see http://ejohn.org/blog/learning-from-twitter/) 1812$(window).scroll(function () { didImgScroll = true; }); 1813 1814var scrollInterval = setInterval(function () { 1815 if (didImgScroll) { 1816 didImgScroll = false; 1817 var newScrollTop = parseInt(window.pageYOffset); 1818 if (newScrollTop > maxScrollTop) { imagesBelowFold(newScrollTop); maxScrollTop = newScrollTop; } 1819 } 1820}, 200); 1821 1822 1823initScrollInterval(); 1824 1825function isInView(elem) { 1826 return $(elem).offset().top - $(window).scrollTop() < 500; 1827} 1828 1829 1830function initScrollInterval() { //functionised so scrolling can be restarted from elsewhere 1831 scrollInterval = setInterval(function () { 1832 if (didScroll) { 1833 didScroll = false; 1834 var newScrollTop = parseInt(window.pageYOffset); 1835 } 1836 }, 100); 1837} 1838 1839 1840var didStickyScroll = false; 1841$(window).scroll(function () { 1842 didStickyScroll = true; 1843 if ($('[data-nq-elements]').length > 0) { 1844 if (isInView($('[data-nq-elements]'))) { 1845 if ($('[data-nq-recommendations="nq-recommendation-upsells"]').attr("data-nq-complete") !== "true") { 1846 nq.nqFeedsApi("recommendations", "nq-recommendation-upsells"); 1847 } 1848 1849 } 1850 1851 } 1852}); 1853 1854$(document).on('click', '[data-nq-elements]', function () { 1855 var tabTarget = $(this).data('nq-elements'); 1856 if (tabTarget == 'visual') { 1857 nq.nqFeedsApi("recommendations", "nq-recommendation-visual") 1858 } 1859}) 1860 1861 1862function imagesBelowFold(scrollVal) { 1863 if (typeof revealTimeout != 'undefined') clearTimeout(revealTimeout); 1864 var dataRevealSrc = $('[data-revealsrc]').filter(':visible'); //images waiting to be revealed 1865 var dataRevealSrcLen = dataRevealSrc.length; 1866 needToEqualize = false; 1867 if (dataRevealSrcLen == 0) { 1868 if ($('.infiniteloadmorebutton').length == 0) clearInterval(scrollInterval); //nothing left to reveal - stop checking //#759501 1869 } else { 1870 //#707428 call centre issue 1871 if (typeof windowHeight == 'undefined') { revealLevel = scrollVal + $(window).height() + revealScrollOffset; } 1872 else { revealLevel = scrollVal + windowHeight + revealScrollOffset; } 1873 revealCount = 0; 1874 recursiveReveal(dataRevealSrc); 1875 } 1876 if (needToEqualize) setTimeout(function () { equalize() }, 500); 1877} 1878 1879function recursiveReveal(dataRevealSrc) { 1880 var t = dataRevealSrc.eq(revealCount); 1881 if (t.offset().top < revealLevel) { //image ready to be revealed 1882 chooseImage(t[0]); 1883 t.removeAttr('data-revealsrc'); 1884 needToEqualize = true; 1885 revealCount = revealCount + 1; 1886 //timeout to give this image time to render fully before checking offset position of next image 1887 if (revealCount < dataRevealSrc.length) revealTimeout = setTimeout(function() { recursiveReveal(dataRevealSrc); }, 100); 1888 } 1889} 1890 1891function chooseImage(thisT) {//cut-down version of chooseImages() 1892 if (thisT.hasAttribute('data-src-large') && thisT.hasAttribute('data-src-small')) { 1893 if (breakpointSM) { thisT.setAttribute('src', thisT.getAttribute('data-src-large')); } 1894 else { thisT.setAttribute('src', thisT.getAttribute('data-src-small')); } 1895 } else { 1896 thisT.setAttribute('src', thisT.getAttribute('data-revealsrc')); 1897 } 1898}
1899//#748566 END 1900 1901//IMAGE CHANGE ON HOVER 1902$(document).on('mouseenter', '[data-hover]:not([data-revealsrc])', function (e) { //#882407 1903 if (!touchScreen) { 1904 $(this).attr('data-src', $(this).attr('src')); 1905 $(this).attr('src', $(this).attr('data-hover')); 1906 } 1907}) 1908$(document).on('mouseleave', '[data-hover]:not([data-revealsrc])', function (e) { //#882407 1909 $(this).attr('src', $(this).attr('data-src')); 1910}) 1911 1912//BACK TO TOP BUTTON 1913var scrollCheck; 1914function initBackToTopButton() { 1915 topBtn = $('#backtotop'); 1916 if (breakpointSM) { 1917 toggleBackToTopButton(); 1918 if (!scrollCheck) { 1919 //Performance improvement - see http://ejohn.org/blog/learning-from-twitter/ 1920 var didScroll = false; 1921 $(window).scroll(function () { didScroll = true; }); 1922 scrollCheck = setInterval(function () { if (didScroll) { didScroll = false; toggleBackToTopButton(); } }, 250); 1923 topBtn.click(function () { $('html, body').animate({ scrollTop: 0 }, animationDuration); }); 1924 } 1925 } else { 1926 topBtn.hide().off('click'); 1927 if (scrollCheck) { clearInterval(scrollCheck); scrollCheck = null; } 1928 } 1929} 1930function toggleBackToTopButton() { 1931 var scrollTop = $(document).scrollTop(); 1932 var topBtnVisible = (topBtn.filter(':visible').length == 1); 1933 if (scrollTop > 300 && !topBtnVisible) topBtn.fadeIn(animationDuration); //button should be visible but isn't 1934 else if (scrollTop <= 300 && topBtnVisible) topBtn.fadeOut(animationDuration); //button shouldn't be visible but is 1935} 1936 1937//Minibasket CSS not correctly applied to vertical flexbox on iPhone 6 1938function miniBasketHeightAdjust() { 1939 //var numCol = 3; var ctaHeight = 156; 1940 //if(menuLayout == 'sliding'){ 1941 var numCol = 5; var ctaHeight = 350; 1942 //} 1943 $('.minibasketitems,.minibasketitem').removeAttr('style'); 1944 $('.minibasketitems').height(windowHeight - ctaHeight); //hardcoded as browser not correctly measuring $('.minibasketother').height() 1945 // 1946 1947 if($('.scrollablebasketitems').length > 0){ 1948 1949 if (!breakpointSM){ 1950 $('.scrollablebasketitems').height($('.minibasketitems').height() - $('.minibasketheading').height()); 1951 }else{ 1952 $('.scrollablebasketitems').height($('.minibasketitems').height() - $('.minibasketheading').height() + 20); 1953 1954 if (breakpointMD){ 1955 $('.minibasketitem').height(($('.minibasketitems').height() - 128) / 4); 1956 }else{ 1957 $('.minibasketitem').height(($('.minibasketitems').height() - 128) / 3); 1958 } 1959 } 1960 1961 1962 1963 }else{ 1964 $('.minibasketitem').height(($('.minibasketitems').height() - 128) / numCol); 1965 } 1966} 1967 1968function showhiddendiv(id) { $('#' + id).slideDown(); } 1969function hidehiddendiv(id) { $('#' + id).slideUp(); } 1970 1971/* #778360 - START */ 1972function initiateContentSpots() { 1973 // To be only initiated if required - contentSpotsLoaded = true / false 1974 1975 var csCols = parseInt( $('.container-listing').width() / $('.container-listing > *').width() ); 1976 if (csCols != "NaN") { 1977 if (csCols > 0) { 1978 if (typeof contentspots != "undefined") { 1979 // Remove all content spots 1980 $(".content-spot").remove() 1981 1982 // Add content spots back in based on their correct location based on the breakpoint 1983 $.eachJSON(contentspots, function (dataKey, dataArray) { 1984 1985 switch (csCols) { 1986 case 2: 1987 insertContentSpot(dataArray.cols2, contentspots_page, dataArray.content, dataArray) 1988 break; 1989 case 3: 1990 insertContentSpot(dataArray.cols3, contentspots_page, dataArray.content, dataArray) 1991 break; 1992 default: 1993 insertContentSpot(dataArray.cols4, contentspots_page, dataArray.content, dataArray) 1994 break; 1995 } 1996 }); 1997 } 1998 } 1999 } 2000 noGaps(); 2001} 2002 2003function insertContentSpot(positionValueInput, pageSize, contentData, contentParent) { 2004 console.log(contentParent) 2005 if (positionValueInput <= pageSize) { 2006 pageNumber = 1 2007 positionValue = positionValueInput; 2008 } 2009 else { 2010 pageNumber = Math.ceil(positionValueInput / pageSize) 2011 positionValue = positionValueInput % pageSize; 2012 } 2013 2014 //console.log("pageNumber:" + pageNumber) 2015 //console.log("positionValue:" + positionValue) 2016 2017 // If no page number set then apply to all pages 2018 if (pageNumber == "") { var divArea = $(".page-wrapper"); }
2018 else { var divArea = $(".page-wrapper[data-page=" + pageNumber + "]"); } 2019 // We need to loop the divArea here to ensure we do this for all pages if required 2020 linkexists = false 2021 if (contentData.link != '' && contentData.link != undefined) { linkexists = true } 2022 2023 var insertHTML = ""; 2024 switch (contentData.type) { 2025 case "image": 2026 var additionalClass = ""; 2027 if (contentParent.size == "2x2") { additionalClass = " float-left" } 2028 insertHTML = '<div class="content-spot' + additionalClass + '" data-size="' + contentParent.size + '"><div class="listing no-hover">' 2029 if (linkexists) { insertHTML += '<a href="' + contentData.link + '">' } 2030 insertHTML += '<img src="' + contentData.value + '" class="fullwidth" />' 2031 if (linkexists) { insertHTML += '</a>' } 2032 insertHTML += '</div></div>' 2033 break; 2034 //case "video": 2035 //break; 2036 case "location": 2037 var additionalClass = ""; 2038 if (contentParent.size == "2x2") { additionalClass = " float-left" } 2039 2040 var locationNumber = (9000 + parseInt(contentData.value)); 2041 locationHTML = $(".content-spots-link-locations #location" + locationNumber).html() 2042 if (locationHTML == "" || locationHTML == undefined) { locationHTML = '<img src="/images/products/content/default.jpg" class="fullwidth" />' } 2043 2044 insertHTML = '<div class="content-spot' + additionalClass + '" data-size="' + contentParent.size + '"><div class="listing no-hover">' 2045 insertHTML += locationHTML 2046 insertHTML += '</div></div>' 2047 break; 2048 } 2049 //console.log("positionValue" + positionValue) 2050 if (positionValue == 1) { 2051 $(insertHTML).insertBefore(divArea.children().eq(positionValue - 1)); 2052 } 2053 else { 2054 $(insertHTML).insertAfter(divArea.children().eq(positionValue - 2)); 2055 } 2056 2057} 2058/* #778360 - END */ 2059 2060//#726681 2061$(document).on('click', '#nav-currencylink', function () { 2062 $(this).toggleClass('currencylink-selected').next().slideToggle(); 2063 var offBtm = $(this).next().offset().top + $(this).next().height(); 2064 if ($(window).scrollTop() < offBtm) $('html,body').animate({ scrollTop: offBtm }); 2065}); 2066 2067$(document).on('click', '#header-currencylink', function () { 2068 $(this).toggleClass('currencylink-selected'); 2069 $('#header-currency').slideToggle(); 2070}); 2071 2072 2073 2074 2075/*#888359*/ 2076$(document).on('change','input#optscheckall', function(){ 2077 if($(this).attr('checked') != 'checked'){ 2078 $('input.checkgroup').attr('checked','checked'); 2079 $('input.checkgroup').prop('checked',true); 2080 $('#optscheckall').attr('checked','checked'); 2081 $('#optscheckall').prop('checked',true); 2082 $('.optcheckpretty span.ghostcheckbox:not(.checkall)').addClass('checked'); 2083 $('#optscheckall').prev('span.checkall').addClass('checked'); 2084 }else{ 2085 $('#optscheckall').removeAttr('checked'); 2086 $('#optscheckall').prop('checked',false); 2087 $('#optscheckall').prev('span.checkall').removeClass('checked'); 2088 } 2089}); 2090 2091$(document).on('change','input.checkgroup', function(){ 2092 if($(this).attr('checked') == 'checked'){ 2093 $('#optscheckall').removeAttr('checked'); 2094 $('#optscheckall').prop('checked',false); 2095 $(this).removeAttr('checked'); 2096 $(this).prop('checked',false); 2097 $(this).prev('span.ghostcheckbox').removeClass('checked'); 2098 $('#optscheckall').prev('span.ghostcheckbox').removeClass('checked'); 2099 }else{ 2100 $(this).attr('checked','checked'); 2101 $(this).prop('checked',true); 2102 $(this).prev('span.ghostcheckbox').addClass('checked'); 2103 2104 } 2105}); 2106 2107$(document).on('click', '.optcheckpretty span.ghostcheckbox', function(){ 2108 if($(this).next('input[type="checkbox"]').attr('checked')!='checked'){ 2109 $(this).next('input[type="checkbox"]').prop('checked',true); 2110 $(this).next('input[type="checkbox"]').attr('checked','checked'); 2111 $(this).addClass('checked'); 2112 if($(this).hasClass('checkall')){ 2113 $('input.checkgroup').attr('checked','checked'); 2114 $('input.checkgroup').prop('checked',true); 2115 $('.optcheckpretty span.ghostcheckbox').addClass('checked'); 2116 } 2117 }else{ 2118 $(this).next('input[type="checkbox"]').prop('checked',false); 2119 $(this).next('input[type="checkbox"]').removeAttr('checked'); 2120 $(this).removeClass('checked'); 2121
2122 $('#optscheckall').removeAttr('checked'); 2123 $('#optscheckall').prop('checked',false); 2124 $('#optscheckall').prev('span.ghostcheckbox').removeClass('checked'); 2125 } 2126}) 2127/*#888359*/ 2128 2129//#891191 START 2130//SCROLLSPY 2131$(document).on('click', '#alternativeImages img', function () { 2132 var linktoIndex = $(this).index(); 2133 var scrollPoint = $('#mainImages > div').eq(linktoIndex).offset().top - heightHeaderTotal; 2134 $('html, body').animate({ scrollTop: scrollPoint }, 200); 2135}); 2136 2137function initScrollSpy() { 2138 if ($('#alternativeImages img').length > 0 && $(window).width() >= 768) { 2139 scrollSpy(); 2140 $(window).on('scroll', scrollSpy); 2141 } else { 2142 $(window).off('scroll', scrollSpy); 2143 } 2144} 2145 2146function scrollSpy() { 2147 var currentScrollTop = $(window).scrollTop() + windowHeight / 2; 2148 for (var k = 0; k < $('#alternativeImages img').length; k++) 2149 if (currentScrollTop > $('#mainImages > div').eq(k).offset().top) 2150 $('#alternativeImages img').eq(k).addClass('selected').siblings().removeClass('selected'); 2151} 2152 2153//MORE/LESS 2154$(document).on('click', '.moreless-btn', function () { 2155 var thisMoreLess = $(this).parents('.moreless').toggleClass('moreless-expanded'); 2156 if (thisMoreLess.hasClass('moreless-expanded')) thisMoreLess.height(thisMoreLess.attr('data-fullheight')); 2157 else thisMoreLess.height(''); 2158}); 2159 2160$(document).ready(function () { 2161 $('.moreless').each(function () { 2162 $(this) 2163 .height('auto').addClass('moreless-expanded').delay(10) 2164 .attr('data-fullheight', $(this).height()).delay(10) 2165 .height('').removeClass('moreless-expanded'); 2166 }); 2167}); 2168 2169//#955370 EXPANDABLE 2170function initExpandable() { 2171 initMaxHeight = $('.expandable').height(); 2172 if ($('.exp-d').outerHeight() > initMaxHeight) $('.expandable .exp-a').addClass('exp-active'); 2173 else $('.expandable .exp-a').removeClass('exp-active'); 2174} 2175 2176$(document).on('click', '.exp-active', function () { 2177 if ($(this).hasClass('exp-clicked')) { 2178 $('.expandable').animate({height: initMaxHeight}, 400, function() { $('.expandable').removeAttr('style'); }); 2179 } else { 2180 $('.expandable').css({height: initMaxHeight, maxHeight: 'none'}).animate({height: $('.exp-d').outerHeight() + $('.exp-a').outerHeight()}, 400); 2181 } 2182 $(this).toggleClass('exp-clicked'); 2183}); 2184 2185//PDP IN VERTICAL IMAGE SCROLL MODE 2186function initPdpImageScrollVertical() { 2187 if ($('[data-pdpimagescrollvertical="1"]').length > 0) { 2188 //TABLET/DESKTOP 2189 if (breakpointSM) { 2190 //Slick 2191 if (slickJsLoaded) $('#mainImages.slick-slider').slick('unslick'); 2192 2193 //SimpleBar 2194 if ($('html.webkit').length == 0) { 2195 if (typeof SimpleBar == 'undefined') { 2196 var s = document.createElement('script'); 2197 s.src = '/javascript/simplebar.min.js'; 2198 var t = document.getElementsByTagName('script')[0]; 2199 t.parentNode.insertBefore(s, t); 2200 $(s).on('load', function () { 2201 var el = new SimpleBar($('#details-inner')[0]); 2202 el.getContentElement(); 2203 }); 2204 } else { 2205 var el = new SimpleBar($('#details-inner')[0]); 2206 el.getContentElement(); 2207 } 2208 } 2209 2210 //MOBILE 2211 } else { 2212 //Slick 2213 if (slickJsLoaded) { 2214 $('#mainImages:not(.slick-initialized)').slick({ arrows: false, dots: true }); 2215 } else { 2216 var s = document.createElement('script'); 2217 s.src = '/javascript/jQuery/slick.js'; 2218 var t = document.getElementsByTagName('script')[0]; 2219 t.parentNode.insertBefore(s, t); 2220 $(s).on('load', function () { 2221 $('#mainImages:not(.slick-initialized)').slick({ arrows: false, dots: true }); 2222 }); 2223 slickJsLoaded = true; 2224 } 2225 } 2226 } 2227} 2228//#891191 END 2229 2230//#904993 START 2231$.fn.putCursorAtEnd = function () { return this.each(function () { var a = $(this), b = this; if (!a.is(":focus")) { a.focus() }
2231 if (b.setSelectionRange) { var c = a.val().length * 2; setTimeout(function () { b.setSelectionRange(c, c) }, 1) } else { a.val(a.val()) } this.scrollTop = 999999 }) }; 2232//#904993 END 2233 2234//#908953 START 2235function listingSlick(elm){ 2236 elm.find('[data-alt]').removeClass('hidden'); 2237 if(elm.find('img').length > 1 && !elm.hasClass('slick-initialized')){ 2238 elm.slick({ 2239 lazyLoad: 'ondemand', 2240 lazyLoadBuffer: 1000, 2241 slidesToShow: 1, 2242 slidesToScroll: 1, 2243 draggable: true, 2244 arrows: true, 2245 dots: false, 2246 infinite:true, 2247 centerPadding: '0', 2248 centerMode: true, 2249 prevArrow: '<span class="arrow_prev pointer icon-leftarrow-small no-hover icon-black"></span>', 2250 nextArrow: '<span class="arrow_next pointer icon-rightarrow-small no-hover icon-black"></span>', 2251 }).on('wheel', (function(e) { 2252 // e.preventDefault(); 2253 //if (e.originalEvent.deltaY < 0) { 2254 // $(this).slick('slickNext'); 2255 //} else { 2256 // $(this).slick('slickPrev'); 2257 //} 2258 })); 2259 } 2260 } 2261 2262$(document).on('mouseenter touchstart','[data-plpaltimgslider="1"] [data-listing="image"]',function(){ 2263 var targetP = $(this).parent().attr('id'); 2264 var targetC = $('#' + targetP + ' > span[data-listing="image"]'); 2265 $(this).children('span').removeClass('hidden').addClass('block'); 2266 listingSlick(targetC); 2267}); 2268 2269$(document).on('click', '.flextabs .tab', function () { 2270 $(this).addClass('selected').siblings().removeClass('selected'); 2271 $('.flextabs .tab').next().hide(); 2272 $(this).next().show(); 2273}); 2274 2275$(document).ready(function(){ $('.flextabs .tab').eq(0).click(); }); 2276//#908953 END 2277 2278//#922523 START 2279function showSwatchData(productCode, imageReference, imageReference_1, manufacturerName, productName, productPrice, link, plainPrice, option1, promoImageURL, imageString) { 2280 if ($('[data-pid="' + productCode + '"] [data-listing="image"]').hasClass('slick-ready')) { 2281 if ($('[data-pid="' + productCode + '"] [data-listing="image"]').hasClass('slick-initialized')) $('[data-pid="' + productCode + '"] [data-listing="image"]').slick('unslick'); 2282 $('[data-pid="' + productCode + '"] [data-listing="image"]').html(imageString); 2283 } else { 2284 $('[data-pid="' + productCode + '"] [data-listing="image"] img').attr('src', imageReference); 2285 $('[data-pid="' + productCode + '"] [data-listing="image"] img').attr('data-url', link); 2286 $('[data-pid="' + productCode + '"] [data-listing="image"] img').attr('data-hover', imageReference_1); 2287 } 2288 $('[data-pid="' + productCode + '"] [data-listing="name"]').attr('href', link); 2289 $('[data-pid="' + productCode + '"] [data-listing="name"]').html(manufacturerName + productName); 2290 $('[data-pid="' + productCode + '"] [data-listing="price"]').html(productPrice); 2291 $('[data-pid="' + productCode + '"] [data-listing="promo"]').replaceWith(promoImageURL); 2292 $('#gtm' + productCode).attr('data-pvariant', option1); 2293 $('#gtm' + productCode).attr('data-pname', productName); 2294 $('#gtm' + productCode).attr('data-pbrand', manufacturerName); 2295 $('#gtm' + productCode).attr('data-pprice', plainPrice); 2296} 2297//#922523 END 2298 2299//#955228 START 2300$(document).on('click', '.imagepopup-link', function(e) { 2301 e.preventDefault(); 2302 $('#pdpLargeImageDiv img').remove(); 2303 $('#pdpLargeImageDiv').append('<img class=no-max src=' + $(this).attr('href') + ' />'); 2304 popup('pdpLargeImage', imagepopupCallback); 2305}); 2306 2307function imagepopupCallback() { 2308 $('#pdpLargeImageDiv').animate({ 2309 scrollLeft: ($('#pdpLargeImageDiv img').width() - $('#pdpLargeImageDiv').width())/2, 2310 scrollTop: ($('#pdpLargeImageDiv img').height() - $('#pdpLargeImageDiv').height())/2 2311 }, animationDuration); 2312} 2313//#955228 END 2314 2315//NQ Related 2316$(document).on('click', '.filter-plusNQ,.filter-minusNQ', function () { 2317 if (breakpointSM){ 2318 $('#filterpopup.nqfacet').fadeIn(10, function () { 2319 initSimplebarFacets(); 2320 $('.filter-overlay').fadeIn(); 2321 $('.main').css('z-index', '1'); 2322 }); 2323 } 2324}); 2325 2326function closeFilter() { 2327 $('#filterpopup.nqfacet').fadeOut(10, function () { 2328 $('.main').css('z-index', '0'); 2329 setTimeout(function(){ 2330 $('.filter-overlay').fadeOut(); 2331 }, 10); 2332 }); 2333} 2334 2335//#1008758 START 2336$(document).ready(function() { 2337 if ($('#header-linkloc.slick-slider').length == 1) { 2338 if (slickJsLoaded) { 2339 initHeaderLinklocSlider(); 2340 } else { 2341 var s = document.createElement('script'); 2342 s.src = '/javascript/jQuery/slick.min.js'; 2343 var t = document.getElementsByTagName('script')[0]; 2344 t.parentNode.insertBefore(s, t); 2345 $(s).on('load', function () { initHeaderLinklocSlider(); }); 2346 slickJsLoaded = true; 2347 } 2348 } 2349}); 2350 2351function initHeaderLinklocSlider() { 2352 $('#header-linkloc:not(.slick-initialized)').slick({ 2353 autoplay: true, autoplaySpeed: $('#header-linkloc').data('slideinterval'), speed: $('#header-linkloc').data('slidespeed'), 2354 prevArrow: '<span class="pointer icon-leftarrow-small icon-white absolute left0-5 top0"></span>', 2355 nextArrow: '<span class="pointer icon-rightarrow-small icon-white absolute right0-5 top0"></span>' 2356 });
2357} 2358//#1008758 END 2359 2360//#1059130 2361function CheckPassword(){ 2362 if($('#forgotemail').val() == '' || !isValidEmailAddress($('#forgotemail').val())){ 2363 $('#passerrormargin').show(); 2364 $('#passerror').show(); 2365 return false; 2366 }else{ 2367 return true; 2368 } 2369} 2370 2371$(document).on('click', '.inactive', function (e) { 2372 e.preventDefault() 2373}); 2374 2375 2376 2377function TogglePassType(objName, objButton, txtShow, txtHide) { 2378 var x = document.getElementById(objName); 2379 if (x.type === "password") { 2380 x.type = "text"; 2381 objButton.innerHTML = txtHide; 2382 } else { 2383 x.type = "password"; 2384 objButton.innerHTML = txtShow; 2385 } 2386 x.focus(); 2387} 2388 2389//#1116016 - start 2390function checkout_push(eventLabel) { 2391 dataLayer.push({ 2392 'event': 'checkout', 2393 'eventCategory': 'Ecommerce', 2394 'eventAction': 'Checkout', 2395 'eventLabel': eventLabel, 2396 'eventValue': dataLayer[0].basketValue, 2397 'ecommerce': { 2398 'currencyCode': chcurrency, 2399 'checkout': { 2400 'actionField': { 2401 'action': 'checkout', 2402 'step': eventLabel 2403 }, 2404 'products': dataLayer[0].basketitems 2405 } 2406 } 2407 }); 2408} 2409//#1116016 - end 2410//#1202757 - start 2411function isLikelyBot() { 2412 try { 2413 var ua = (navigator.userAgent || "").toLowerCase(); 2414 2415 // Known bots & crawlers 2416 var botPatterns = [ 2417 /googlebot/, /bingbot/, /slurp/, /duckduckbot/, 2418 /baiduspider/, /yandexbot/, /facebookexternalhit/, 2419 /twitterbot/, /linkedinbot/, /applebot/, 2420 /semrushbot/, /ahrefsbot/, /mj12bot/, 2421 /petalbot/, /screaming frog/i, /crawler/, /spider/, /bot/ 2422 ]; 2423 2424 for (var i = 0; i < botPatterns.length; i++) { 2425 if (botPatterns[i].test(ua)) { 2426 return true; 2427 } 2428 } 2429 2430 // Selenium / Headless Chrome indicators 2431 if (navigator.webdriver) { 2432 return true; 2433 } 2434 2435 if (ua.indexOf("headlesschrome") !== -1) { 2436 return true; 2437 } 2438 2439 // Playwright / Puppeteer artifacts 2440 if (window.__playwright__binding__ || 2441 window.__pwInitScripts || 2442 window._phantom || 2443 window.callPhantom) { 2444 return true; 2445 } 2446 2447 // Missing plugins is common in headless browsers 2448 if (navigator.plugins && navigator.plugins.length === 0) { 2449 return true; 2450 } 2451 2452 return false; 2453 2454 } catch (e) { 2455 // Fail open: if detection errors, assume it's not a bot 2456 return false; 2457 } 2458} 2459//#1202757 - end
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.