1var lazyInstance = false; 2var lazyResponsive = false; 3var slidersLoaded = 0; 4 5$(document).ready(function() { 6 $('.item-tribe').on('click', function(event) { 7 event.preventDefault(); 8 9 let $menu = $(this).closest('.my-account-links'); 10 let $nav = $menu.find('.nav-tribe'); 11 12 $(this).toggleClass('open') 13 if ($nav.hasClass('unfolded')) { 14 $nav.removeClass('unfolded') 15 $nav.slideToggle(300) 16 } else { 17 setTimeout(function () {$nav.addClass('unfolded')}, 150) 18 $nav.slideToggle(300) 19 } 20 }); 21 $('.sub-items .tab-earn-points:not(.sub-sub-tab)').on('click', function() { 22 let $menu = $(this).closest('.my-account-links'); 23 $menu.find('.nav-earn-points').slideToggle(300); 24 $(this).toggleClass('open') 25 }); 26 $('.sub-items .tab-vip-info:not(.sub-sub-tab)').on('click', function() { 27 let $menu = $(this).closest('.my-account-links'); 28 $menu.find('.nav-info').slideToggle(300); 29 $(this).toggleClass('open') 30 }); 31 $('.sub-items .sub-sub-tab').on('click', function() { 32 $(this).parent().children().hide(300); 33 let catsToShow = $(this).data('sub'); 34 $('.'+catsToShow).show(); 35 }); 36 $('.back-to-sub').on('click', function() { 37 $(this).parent().parent().children().hide(300); 38 $(this).parent().parent().children('li:not(.sub-sub-cats)').show(300); 39 }); 40 41 lazyInstance = $('.lazy').Lazy({ 42 chainable: false, 43 afterLoad : function (e) { 44 e.prev('.product-overlay').show(); 45 $(e).removeClass('lazy-loading'); 46 $(e).addClass('lazy-loaded'); 47 let productCardWrap = $('.productCardWrap'); 48 if (productCardWrap) { 49 productCardWrap.equalHeights(); 50 } 51 } 52 }); 53 54 if (window.innerWidth < 768) { 55 $('.no-swiper-container').removeClass('no-swiper-container').addClass('swiper-container'); 56 } 57 58 if (window.innerWidth > 767) { 59 $('.crossselling_wrap.home-slider-category .swiper-container').removeClass('swiper-container').addClass('no-swiper-container'); 60 } 61 if ($('#author_popover').length != 0) { 62 if ($(window).width() < 768) { 63 $('#author_popover').fu_popover({ 64 trigger: 'click', 65 content: $('#authorContent').html(), 66 title: '', 67 placement: 'bottom' 68 }); 69 $(document).mouseup(function (e){ 70 var div = $(".fu_popover_content_default"); 71 if (!div.is(e.target) 72 && div.has(e.target).length === 0) { 73 $('#author_popover').fu_popover('hide'); 74 } 75 }); 76 } else { 77 $('#author_popover').fu_popover({ 78 trigger: 'hover', 79 content: $('#authorContent').html(), 80 title: '', 81 placement: 'bottom', 82 width: '160px', 83 }); 84 $('body').on('mouseleave', '.fu_popover_content_default', function(e) { 85 $('#author_popover').fu_popover('hide'); 86 }); 87 $('body').on('mouseleave', '.author-image-wrapper-wrapper', function(e) { 88 var div = $('.fu_popover_content_default'); 89 var arrow = $('.arrow_top_default'); 90 if(!div.is(e.relatedTarget) && !arrow.is(e.relatedTarget)) 91 $('#author_popover').fu_popover('hide'); 92 }); 93 } 94 95 } 96 updateBreadcrumbPosition(); 97 98 alternateHeader.init(); 99 100 var target = $('#affix'); 101 // Show affix on scroll. 102 if (target !== null && $('.fixedHeader').length && $('.fixedHeader').css('position') != 'fixed') { 103 var position = target.offset(); 104 var showAffixOnScroll = function() { 105 var height = $(window).scrollTop(); 106 if ($('body').hasClass('orderPage')) { 107 positionAffixMenu(); 108 } 109 if (height > position.top) { 110 if (window.innerWidth > 767) { 111 target.addClass('affix'); 112 $('body').addClass('affix-body'); 113 } 114 $('#tmcategories').css('margin-top', $('#affix').height()-20); 115 if (!$('body').hasClass('orderPage')) { 116 positionAffixMenu(); 117 } 118 $('#tmcategories').addClass('affix-shown'); 119 } 120 else { 121 target.removeClass('affix'); 122 $('body').removeClass('affix-body'); 123 $('#tmcategories').css('margin-top', 0); 124 $('#tmcategories').removeClass('affix-shown'); 125 alternateHeader.hideDropdown(); 126 } 127 }; 128 showAffixOnScroll(); 129 window.addEventListener('scroll', function () { 130 showAffixOnScroll(); 131 $('.ac_results').hide(); 132 }); 133 } 134 135 var ekomiHidden = false; 136 var animationCompleted = true; 137 var hideEkomiOnScroll = function(closedMenu = false) { 138 const ANIMATE_DURATION = 200;
139 const ANIMATE_EASING = 'swing'; 140 if (window.innerWidth < 768) { 141 var height = $(window).scrollTop(); 142 if ($('body').hasClass('without_timerbanner_mobile')) { 143 mobileBannerHeight = 0; 144 } 145 var topWithEkomi = mobileBannerHeight + 128 + 'px'; 146 var topWithoutEkomi = mobileBannerHeight + 92 + 'px'; 147 if (height > 0 || $('#catSmall').is(':visible')) { 148 if (!ekomiHidden && animationCompleted) { 149 animationCompleted = false; 150 $('.tp-mobile-wrapper').animate({height: 'auto'}, ANIMATE_DURATION, ANIMATE_EASING); 151 $('.ac_results').removeClass('with-ekomi').css('top', topWithEkomi).animate({top: topWithoutEkomi}, ANIMATE_DURATION, ANIMATE_EASING, function () { 152 $(this).addClass('without-ekomi'); 153 }); 154 $('.tp-mobile-wrapper').hide(); 155 $('.mobile_header_logo_wrapper').addClass('without-ekomi'); 156 $('#catSmall').addClass('without-ekomi'); 157 $('.fixedHeader').animate({marginTop: '50px'}, ANIMATE_DURATION, ANIMATE_EASING); 158 $('.small_header_logo_wrapper').animate({top: '0px'}, ANIMATE_DURATION, ANIMATE_EASING, function () { 159 ekomiHidden = true; 160 animationCompleted = true; 161 }); 162 if (typeof opcPage !== 'undefined' && $('.grecaptcha-badge').length) { 163 $('.grecaptcha-badge').css('top', '110px') 164 } 165 } 166 } else { 167 if ((ekomiHidden && animationCompleted) || closedMenu) { 168 animationCompleted = false; 169 $('.tp-mobile-wrapper').animate({height: 'auto'}, ANIMATE_DURATION, ANIMATE_EASING); 170 $('.ac_results').removeClass('without-ekomi').css('top', topWithoutEkomi).animate({top: topWithEkomi}, ANIMATE_DURATION, ANIMATE_EASING, function () { 171 $(this).addClass('with-ekomi'); 172 }); 173 $('.mobile_header_logo_wrapper').removeClass('without-ekomi'); 174 $('.tp-mobile-wrapper').show(); 175 $('#catSmall').removeClass('without-ekomi'); 176 $('.fixedHeader').animate({marginTop: '86px'}, ANIMATE_DURATION, ANIMATE_EASING); 177 $('.small_header_logo_wrapper').animate({top : '36px'}, ANIMATE_DURATION, ANIMATE_EASING, function () { 178 ekomiHidden = false; 179 animationCompleted = true; 180 }); 181 if (typeof opcPage !== 'undefined' && $('.grecaptcha-badge').length) { 182 $('.grecaptcha-badge').css('top', '148px') 183 } 184 } 185 } 186 } 187 }; 188 hideEkomiOnScroll(); 189 window.addEventListener('scroll', function () { 190 hideEkomiOnScroll(); 191 }); 192 193 var observer = new MutationObserver(function (mutations) { 194 mutations.forEach(function( mutation ) { 195 var newNodes = mutation.addedNodes; 196 if (newNodes !== null) { 197 var nodes = $(newNodes); 198 nodes.each(function() { 199 var node = $( this ); 200 if (node.hasClass('ac_results')) { 201 changeAcBlockPossition(node); 202 } 203 }); 204 } 205 }); 206 }); 207 208 observer.observe($('body')[0], {childList: true}); 209 210 if ($('.webkit-gap').length) { 211 new ResizeObserver((entries) => { 212 entries.forEach((entry) => { 213 document.documentElement.style.setProperty('--webkit-footer-gap', `${entry.contentRect.height}px`); 214 }); 215 }).observe(document.querySelector('.webkit-gap')); 216 } 217 function openMainCategory() { 218 if (typeof id_category != 'undefined' && $('.cat-'+id_category+' .subcategory').length){ 219 $('.cat-'+id_category+' .subcategory').addClass('open'); 220 $('#catSmall').addClass('menu-open'); 221 } 222 else if(typeof id_category_parent != 'undefined' && $('.cat-'+id_category_parent+' .subcategory').length) { 223 $('.cat-'+id_category_parent+' .subcategory').addClass('open'); 224 $('#catSmall').addClass('menu-open'); 225 } 226 } 227 function changeAcBlockPossition(ac_block) 228 { 229 if (window.innerWidth < 768) { 230 if ($(".tp-mobile-wrapper").length && $(".tp-mobile-wrapper").css('height') !== '0px') { 231 ac_block.addClass('with-ekomi'); 232 } else { 233 ac_block.addClass('without-ekomi'); 234 } 235 } 236 } 237 238 window.addEventListener('resize', function() { 239 if (window.innerWidth > 767) { 240 $('.fixedHeader').css('margin-top', '0'); 241 $('.tp-mobile-wrapper').hide(); 242 } else { 243 $('#affix').removeClass('affix'); 244 $('body').removeClass('affix-body'); 245 hideEkomiOnScroll(); 246 } 247 }); 248 249 $('.footer .footer-menu-toggle').click(function() { 250 var pageWidth = $("html").width(); 251 if (pageWidth < 768) { 252 $(this).parents('.link-block').find('ul').toggle(); 253 $(this).parents('.link-block').find('i').toggleClass('fa-plus fa-minus'); 254 $(this).toggleClass('open'); 255 } 256 }); 257 258 $('body').on('dblclick', '.mobile-wrapper .header-menu-toggle', function(event) { 259 event.preventDefault(); 260 return false;
261 }); 262 $('.jsDropdownToggler').dblclick(function(event) { 263 event.preventDefault(); 264 return false; 265 }); 266 267 let scrollPosition; 268 $('body').on('click', '.mobile-wrapper .header-menu-toggle, .categoryPage .back', function(event){ 269 event.preventDefault(); 270 scrollPosition = $(window).scrollTop(); 271 if (!$(this).hasClass('open')) { 272 if (typeof(id_category) != 'undefined' && !$(this).hasClass('back')) { 273 openMainCategory(); 274 } 275 $('#catSmall').show(); 276 hideEkomiOnScroll(); 277 } 278 $(this).toggleClass('open'); 279 $('body').addClass('menu-open'); 280 return false; 281 }); 282 $('body').on('click', '.mobile_header_logo_wrapper .header-menu-toggle.open', function(){ 283 $('#catSmall').hide(); 284 $('.mobile-wrapper .header-menu-toggle').toggleClass('open'); 285 $('body').removeClass('menu-open'); 286 $('.category .subcategory').removeClass('open'); 287 openMainCategory(); 288 hideEkomiOnScroll(true); 289 $(window).scrollTop(scrollPosition); 290 }); 291 $('body').on('click', '#catSmall #allseedbanks>a', function(event){ 292 event.preventDefault(); 293 $('#catSmall #allseedbanks').children('ul').toggle(); 294 }); 295 $('body').on('click', '#catSmall .toggable>a', function(event){ 296 event.preventDefault(); 297 $(this).siblings('ul').toggle(); 298 }); 299 $('body').on('click', '#catSmall .category a.subcats', function(event){ 300 event.preventDefault(); 301 $(this).parent().find('.subcategory').toggleClass('open'); 302 $('#catSmall').toggleClass('menu-open'); 303 }); 304 $('body').on('click', '#catSmall .subcategory .back', function(event){ 305 event.preventDefault(); 306 $(this).parent().removeClass('open'); 307 $('#catSmall').removeClass('menu-open'); 308 return false; 309 }); 310 311 $('#tmcategories #cat a.sub').click(function(event){ 312 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && window.outerWidth <= 1024 ) { 313 event.preventDefault(); 314 } 315 }); 316 317 $('#currencySign').click(function(){ 318 $(this).toggleClass('active'); 319 $('#currenciesList').toggle(); 320 return false; 321 }); 322 323 if ($('.full-width').length) { 324 $('.full-width').each(function () { 325 if (!$(this).next().hasClass('full-width-dummy-height')) { 326 $(this).after('<div class="full-width-dummy-height"></div>'); 327 } 328 fullWidthSupport(); 329 }); 330 } 331 332 $('body').on('click', function(event) { 333 if ($('.languages_block_top').hasClass('open')) { 334 $('.languages_block_top').toggleClass('open'); 335 $('.languagesSmall').toggleClass('open'); 336 } 337 if ($('.currencies_block_top').hasClass('open')) { 338 $('.currencies_block_top').toggleClass('open'); 339 $('.currencySmall').toggleClass('open'); 340 } 341 $('.your-account').find('li.open').removeClass('open'); 342 }); 343 344 $('.languagesSmall .selected_language').on('click', function(event) { 345 event.preventDefault(); 346 $('body').trigger('click'); 347 $('.languagesSmall').toggleClass('open'); 348 $('.languages_block_top').toggleClass('open'); 349 return false; 350 }); 351 352 $('.langSelector').click(function(event) { 353 event.preventDefault(); 354 if (window.innerWidth < 768) { 355 $('.languagesSmall').toggleClass('open'); 356 $('.languages_block_top').toggleClass('open'); 357 } 358 return false; 359 }); 360 361 //setBlogSearchFrom(); 362 adjustPullQuotes(); 363 364 $('.currencySmall .selected_currency').on('click', function(event){ 365 event.preventDefault(); 366 if (window.innerWidth < 768) { 367 $('.currencySmall').toggleClass('open'); 368 $('.currencies_block_top').toggleClass('open'); 369 } 370 return false; 371 }); 372 373 $('.currencySelector').click(function(){ 374 $('body').trigger('click'); 375 $('.currencySmall').toggleClass('open'); 376 $('.currencies_block_top').toggleClass('open'); 377 return false; 378 }); 379 380 $(window).resize(function(){ 381 fullWidthSupport(); 382 positionAffixMenu(); 383 updateBreadcrumbPosition(); 384 setVideoHeight(); 385 }); 386 387 $(window).scroll(function () { 388 if ($(this).scrollTop() > 100) { 389 $('.scrollup').fadeIn(); 390 } else { 391 $('.scrollup').fadeOut(); 392 } 393 }); 394 395 $('.scrollup').click(function () { 396 $("html, body").animate({ 397 scrollTop: 0 398 }, 600); 399 return false; 400 }); 401 402 if ($('body').attr('data-algolia-item-id')) { 403 var articleReadAjaxInit = false; 404 405 var cssArticleBodyClass = ''; 406 //blog 407 if ($('.newsContent').length) { 408 cssArticleBodyClass = 'newsContent'; 409 } 410 //cms 411 if ($('.rte.accordion-body').length) { 412 cssArticleBodyClass = 'rte accordion-body'; 413 } 414 //growguide 415 if ($('.detail-container').length) { 416 cssArticleBodyClass = 'detail-container'; 417 } 418 419 if (cssArticleBodyClass) { 420 var el = document.getElementsByClassName(cssArticleBodyClass)[0]; 421 if (typeof el !== 'undefined') { 422 var elCoordinate = el.getBoundingClientRect(); 423 424 window.onscroll = function() { 425 if(!articleReadAjaxInit && typeof algolia_query_id !== 'undefined' && parseInt($(window).scrollTop() + $(window).height()) >= parseInt(elCoordinate.bottom)) { 426 articleReadAjaxInit = true; 427 var type = 'listing'; 428 if (typeof algolia_autocomplete_search !== 'undefined') { 429 type = 'autocomplete'; 430 } 431 var data = { 432 'query_id': algolia_query_id, 433 'type': type 434 }; 435 algolia.saveEventData(data); 436 $.ajax({ 437 type: 'POST', 438 url: baseDir+'modules/algolia/ajax.php', 439 data: 'ajaxReadArticle=1&id_article=' + $('body').attr('data-algolia-item-id') + '&id_lang=' + lang_id, 440 dataType: 'json', 441 success: function(data) { 442 }, 443 error: function(XMLHttpRequest, textStatus, errorThrown) { 444 } 445 }); 446 } 447 }; 448 } 449 } 450 } 451
452 $(document).on('change', '.product_list.listing .ajax_block_product .right_block .combinations-block .ipa_id', function() { 453 var oldPrice = $(this).closest('.product_list.listing .ajax_block_product .right_block').find('.pricesBlock .discount'); 454 var points = $(this).find('option:selected').data('tribe-points'); 455 if (points) { 456 $(this).closest('.right_block').find('.price-points .points-val').html(points); 457 if ($(this).find('option').length > 1) { // not implemented for multiple combinations 458 oldPrice.hide(); 459 } 460 } else { 461 var price = $(this).find('option:selected').data('price'), 462 originalPrice = $(this).find('option:selected').data('original-price'); 463 if (price) { 464 $(this).closest('.product_list.listing .ajax_block_product .right_block').find('.pricesBlock .price').html(wrapPriceInHtml(price)); 465 } 466 if (originalPrice) { 467 oldPrice.html(wrapPriceInHtml(originalPrice)); 468 } 469 var priceWithoutReduc = $(this).find('option:selected').data('price-without-reduc'); 470 var priceFinal = $(this).find('option:selected').data('price-final'); 471 if (priceWithoutReduc) { 472 if (priceWithoutReduc - priceFinal > 0.01) { 473 oldPrice.show(); 474 } 475 else { 476 oldPrice.hide(); 477 } 478 } 479 } 480 var earnPoints = $(this).find('option:selected').data('tribe-earn-points'); 481 var $earnPointsBlock = $(this).closest('.product_list.listing .ajax_block_product').find('.product-item-earn-points'); 482 if (earnPoints) { 483 $earnPointsBlock.addClass('extraPointsShow').find('span').show().find('.gift_points_value').text(earnPoints); 484 } 485 else { 486 $earnPointsBlock.removeClass('extraPointsShow').find('span').hide(); 487 } 488 }); 489 490 $('body').on('click', function(e) { 491 if ($(e.target).closest('.jsDropdown .jsDropdownToggler').length) { 492 $('.jsDropdownList').each(function(index, element) { 493 if($(e.target).closest('.jsDropdown').data('selector') != 'undefined') { 494 if ($(element).parent().data('selector') != $(e.target).closest('.jsDropdown').data('selector')) { 495 $(element).hide(); 496 } 497 else { 498 $(element).toggle(); 499 } 500 } 501 else { 502 $(e.target).closest('.jsDropdown').find('.jsDropdownList').toggle(); 503 } 504 }); 505 } 506 else { 507 if (!$(e.target).closest('.jsDropdown').length) { 508 $('.jsDropdown .jsDropdownList').hide(); 509 } 510 } 511 if ($(e.target).closest('.jsDropdown .jsDropdownList li:not(.optgroup):not(.selected)').length) { 512 $($(e.target).closest('.jsDropdown').data('selector')).val($(e.target).closest('.jsDropdown .jsDropdownList li:not(.optgroup)').data('value')); 513 $(e.target).closest('.jsDropdown .jsDropdownList').find('li:not(.optgroup).selected').removeClass('selected'); 514 $(e.target).closest('.jsDropdown .jsDropdownList li:not(.optgroup)').addClass('selected'); 515 $(e.target).closest('.jsDropdown').find('.jsDropdownToggler').html($(e.target).closest('.jsDropdown .jsDropdownList li:not(.optgroup)').html()); 516 $(e.target).closest('.jsDropdown').find('.jsDropdownList').hide(); 517 $($(e.target).closest('.jsDropdown').data('selector')).trigger('change'); 518 } 519 }); 520 521 $(document).keydown(function(e) { 522 var keyCode = e.which || e.keyCode; 523 // 1-9 a-z 524 if (!(keyCode >= 48 && keyCode <= 57) && !(keyCode >= 65 && keyCode <= 90)) { 525 return; 526 } 527 528 var activeDropdown = $('.jsDropdown').find('.jsDropdownList:visible'); 529 if (!activeDropdown.length) { 530 return; 531 } 532 533 var key = e.key.toLowerCase() || String.fromCharCode(keyCode).toLowerCase(); 534 var elems = activeDropdown.children().filter(function() { 535 return $(this).text().trim().substr(0,1).toLowerCase() == key; 536 }); 537 538 if (elems.length) { 539 var elem = elems.first(); 540 541 activeDropdown.animate({ 542 scrollTop: elem.offset().top - activeDropdown.offset().top + activeDropdown.scrollTop() 543 }, 500); 544 } 545 }); 546 547 $('.jsDropdown.selectProductAttribute').each(function() { 548 select = $($(this).data('selector')); 549 if (select.length) { 550 if (!select.find('option[selected]').length) { 551 $('.jsDropdown.selectProductAttribute .jsDropdownList li').first().click(); 552 } 553 } 554 }); 555 556 $('#nb_item').change(function() { 557 $('#pagination_form').submit(); 558 }); 559 560 $('.number_controls .number_dec').click(function() { 561 var next_value = parseInt($(this).siblings('input[type="number"]').first().val()) - 1; 562 if (!$(this).siblings('input[type="number"]').attr('min') || next_value >= parseInt($(this).siblings('input[type="number"]').attr('min'))) { 563 $(this).siblings('input[type="number"]').first().val(next_value); 564 updatePriceAfterQuantity(next_value); 565 } 566 }); 567 $('#quantity_wanted').keyup(function() { 568 var next_value = $('#quantity_wanted').val(); 569 if( next_value != ""){ 570 updatePriceAfterQuantity(next_value); 571 } 572 }); 573 $('.number_controls .number_inc').click(function() { 574 var next_value = parseInt($(this).siblings('input[type="number"]').first().val()) + 1; 575 if (!$(this).siblings('input[type="number"]').attr('max') || next_value <= parseInt($(this).siblings('input[type="number"]').attr('max'))) { 576 $(this).siblings('input[type="number"]').first().val(next_value); 577 updatePriceAfterQuantity(next_value); 578 } 579 }); 580 581 if ($('.listing-features .features-nav .feature-toggle').length) { 582 $('.listing-features .features-nav .feature-toggle').click(function(e) { 583 e.preventDefault(); 584 if ($(this).data('target') && $($(this).data('target')).length) { 585 $(this).siblings().removeClass('active'); 586 $('.listing-features .feature-to-be-toggled.active').removeClass('active'); 587 $(this).addClass('active'); 588 $($(this).data('target')).addClass('active'); 589 } 590 }); 591 } 592 593 if ($('.categories-menu').length) { 594 $('.categories-menu .top-category>a').click(function(e) { 595 if ($(e.target).is('span')) { 596 return; 597 } 598 e.preventDefault(); 599 if ($(this).parent().find('.sub-categories').length) { 600 601 if ($(this).parent().find('.sub-categories').hasClass('open')) {
602 $(this).parent().find('.sub-categories').slideUp(300).removeClass('open'); 603 $(this).closest('.top-category').removeClass('open'); 604 } 605 else { 606 $(this).parent().siblings().each(function() { 607 if ($(this).find('.sub-categories')) { 608 $(this).find('.sub-categories').slideUp(300).removeClass('open'); 609 } 610 }); 611 $(this).parent().find('.sub-categories').slideDown(300).addClass('open'); 612 $('.categories-menu .top-category').removeClass('open'); 613 $(this).closest('.top-category').addClass('open'); 614 } 615 } 616 }); 617 $('.categories-menu .closeDropdown').click(function() { 618 $('.categories-menu').removeClass('open'); 619 }); 620 $('.categories-pop').click(function(e) { 621 e.preventDefault(); 622 $('.categories-menu').addClass('open'); 623 $('.categories .top-category').each(function() { 624 $(this).removeClass('open').find('.sub-categories').removeClass('open').hide(); 625 }); 626 $('.categories .top-category').first().addClass('open').find('.sub-categories').addClass('open').show(); 627 }); 628 } 629 630 $('#wishlist-filter .filter-title').click(function(e) { 631 e.preventDefault(); 632 $('#wishlist-filter .wishlist-form').slideToggle(); 633 }); 634 635 $('.videos-filtering .search-keywords form .search-icon').click(function() { 636 $(this).closest('form').submit(); 637 }); 638 $('.video-iframe-wrapper').click(function(e) { 639 $(this).addClass('video-play'); 640 }); 641 642 $('.piscesslider').find('img').on('load', function() { 643 fullWidthSupport(); 644 }); 645 646 displayProductsRating(); 647 648 // Modules/seedslimitations 649 var ensureLimitationsModal = function() { 650 if ($('#limitationsPopup').length) { 651 return $('#limitationsPopup'); 652 } 653 654 var $popup = $('<div>', {id: 'limitationsPopup', class: 'limitations-popup'});
655 var $overlay = $('<div>', {class: 'limitations-popup-overlay'}); 656 var $window = $('<div>', {class: 'limitations-popup-window'}); 657 var $close = $('<button>', {type: 'button', class: 'limitations-popup-close', 'aria-label': 'Close'}); 658 var $content = $('<div>', {class: 'limitations-popup-content'}); 659 660 $window.append($close).append($content); 661 $popup.append($overlay).append($window); 662 $('body').append($popup); 663 664 return $popup; 665 }; 666 667 var closeLimitationsModal = function() { 668 $('#limitationsPopup').removeClass('is-visible'); 669 $('body').removeClass('limitations-popup-open'); 670 }; 671 672 var showLimitationsModal = function(jsonData) { 673 var $popup = ensureLimitationsModal(); 674 var $content = $popup.find('.limitations-popup-content'); 675 var $sourceBlock = null; 676 var $message = null; 677 678 if ('undefined' != typeof(jsonData.seedsLimit) && $('#limitSeedsBlock').length) { 679 $sourceBlock = $('#limitSeedsBlock'); 680 } 681 else if ('undefined' != typeof(jsonData.productsLimit) && $('#limitProductsBlock').length) { 682 $sourceBlock = $('#limitProductsBlock'); 683 } 684 685 if (!$sourceBlock || !$sourceBlock.length) { 686 return; 687 } 688 689 $message = $('<div>', {class: 'limitations-popup-message'}).html($sourceBlock.html()); 690 $message.find('#productsCategory').text(jsonData.categoryName || ''); 691 $message.find('#productsLimit').text(jsonData.productsLimit || ''); 692 $message.find('#seedsLimit').text(jsonData.seedsLimit || ''); 693 $message.find('#seedsCount').text(jsonData.seedsCount || ''); 694 695 if ($('#add-to-cart-popup').length && typeof ajaxCart !== 'undefined' && typeof ajaxCart.closeAddToCartModal === 'function') { 696 ajaxCart.closeAddToCartModal(true); 697 } 698 699 $('#add-to-cart-popup').find('#added-product-container, .quantity-wrap').removeClass('loading'); 700 $('#add_to_cart').removeClass('loading').find('input').removeAttr('disabled'); 701 $('.ajax_add_to_cart_button').removeAttr('disabled').closest('div').removeClass('loading'); 702 $('.shopping_cart .dropdown-block').removeClass('load'); 703 704 $content.html($message); 705 $popup.addClass('is-visible'); 706 $('body').addClass('limitations-popup-open'); 707 }; 708 709 $(document).on('click', '#limitationsPopup .limitations-popup-overlay, #limitationsPopup .limitations-popup-close', function() { 710 closeLimitationsModal(); 711 }); 712 713 $(document).ajaxSuccess(function(event, XMLHttpRequest, ajaxOptions) { 714 if ('string' == typeof(XMLHttpRequest.responseText)) { 715 try { 716 var jsonData = JSON.parse(XMLHttpRequest.responseText); 717 } catch (e) { 718 return; 719 } 720 } 721 else { 722 var jsonData = XMLHttpRequest.responseText; 723 } 724 725 if ('object' == typeof(jsonData) && 'undefined' != typeof(jsonData.seedsLimit)) { 726 showLimitationsModal(jsonData); 727 return; 728 } 729 730 if ('object' == typeof(jsonData) && 'undefined' != typeof(jsonData.productsLimit)) { 731 showLimitationsModal(jsonData); 732 return; 733 } 734 if ($('#add-to-cart-popup').length) { 735 $('#add-to-cart-popup').find('#added-product-container').removeClass('loading'); 736 } 737 }); 738 739 $('#cat > li').on('mouseenter', function() { 740 var li = $(this), id = li.data('id'); 741 742 if ((typeof _tmcategories_data == 'undefined') || !(id in _tmcategories_data) || li.find('> .container').length) { 743 return; 744 } 745 746 $(_tmcategories_data[id]).find('> .container').appendTo(li); 747 if (id === 'brands') { 748 setBrandsDropdownPosition(); 749 } 750 }); 751 752 window.addEventListener('resize', function() { 753 setBrandsDropdownPosition(); 754 }); 755 756 function setBrandsDropdownPosition() 757 { 758 let el = document.getElementsByClassName('cat-brands')[0]; 759 if (typeof el !== 'undefined') { 760 let rect = el.getBoundingClientRect(); 761 $('.cat-brands .container').css({'transform': 'unset', 'left': rect.left}); 762 } 763 } 764 765 $('#cat.custommenu > li').on('mouseenter', function() { 766 if ($(this).data('id') === 'label') { 767 const custommenuBlockPos = this.getBoundingClientRect(); 768 $(this).find('.container').css({'transform': 'unset', 'left': custommenuBlockPos.left - 35}); 769 } 770 }); 771
772 wishlist.init(); 773 geoSettingsBlock.init(); 774 TmCategories.init(); 775 776 uploadVideos(); 777 778 // readd events to unstarted popup images 779 $(document).on('updateVideosList', function(e, data) { 780 if($(data).hasClass('vimeo')) 781 addClickOnVimeo(data); 782 else 783 addClickOnYoutube(data); 784 }); 785 786 $('body').on('click', '.faq_accorion dt', function () { 787 $(this).toggleClass('open') 788 .next().slideToggle(); 789 }); 790 791 // Dynamic footer JS 792 793 $('span.dynamicfooter-block-header:not(.az-header)').on('click', function() 794 { 795 $(this).toggleClass('open'); 796 $(this).nextAll('ul').first().children('li').toggle(); 797 }); 798 799 $('span.az-header').on('click', function() 800 { 801 $(this).toggleClass('open'); 802 $('.mobile-az-container').toggle(); 803 }); 804 805 if (window.innerWidth < 768) { 806 807 $('.dynamicfooter-no-title-block').hide(); 808 $('.dynamicfooter-no-title-block').nextAll().first('ul').hide(); 809 810 811 if ($('.az-header').length > 0) { 812 var selector_ul = '.az-header+.dynamicfooter-columns-3'; 813 if ($('.az-header+.dynamicfooter-columns-4').length > 0) { 814 selector_ul = '.az-header+.dynamicfooter-columns-4'; 815 } 816 817 var a_links = $(selector_ul + ' li a'); 818 819 a_links.sort((a, b) => a.innerText.localeCompare(b.innerText)); 820 821 var az_ranges_array = []; 822 var az_letters_array = []; 823 $('[data-az-range]').each(function () { 824 az_ranges_array.push($(this).data('az-range').split(',')); 825 az_letters_array.push([$(this).data('az-letters')]); 826 }); 827 828 for (var i = 0; i < az_ranges_array.length; i++) { 829 a_links.each(function () { 830 if (az_ranges_array[i].includes($(this).text().substr(0, 1))) { 831 $('.dynamicfooter-columns-' + az_letters_array[i]).append('<li><a href="' + $(this)[0].href + '">' + $(this).text() + '</a></li>'); 832 } 833 }); 834 } 835 $('.az-header').nextAll('ul').first().children('li').hide(); 836 } 837 } 838 839 if ($('.video-window').length) { 840 $('.video-window').on('click', function () { 841 $('.video-window img').hide(); 842 $('.video-window video').show(); 843 $('.video-window video').get(0).play(); 844 }); 845 846 $('#copy-link').on('click', function () { 847 copyStringToClipboard(location.href); 848 $("#copyConfirm").show().delay(1500).fadeOut(); 849 }) 850 } 851 852 $('body').on('click', '.share-link.copy', function(e){ 853 e.preventDefault(); 854 copyStringToClipboard(window.location.href); 855 $(this).prepend('<div id="copy-success">'+$(this).data('copy-success')+'</div>'); 856 setTimeout(function () { 857 $('#copy-success').fadeOut(0, function () { 858 $(this).remove(); 859 }) 860 }, 3000); 861 }); 862 863 // Table of contents START 864 copyTableOfContents(); 865 866 $(document).on('click', '.accordion-body a[href^="#"]', function (e) { 867 e.preventDefault(); 868 869 if ($('body').attr('id') === 'product') { 870 return; 871 } 872 873 var anchor = $(this).attr('href').substr(1); 874 if (anchor && $('#'+anchor).length > 0) { 875 if (!$(this).closest('#main_table_of_contents').length) { 876 e.preventDefault(); 877 } 878 let extraHeight = 0; 879 let extraHeightMobile = 0; 880 if (anchor.indexOf('brands-section') === 0) { //add some extra scroll for sticky alphabet section on seedbank page 881 extraHeight = $('.brands-navigation').height(); 882 extraHeightMobile = 15; 883 } 884 var headerHeight = $('#affix').height() + extraHeight || 0; 885 if ($(window).scrollTop() < 110) { 886 headerHeight = 135 + extraHeight; 887 } 888 if ($( window ).width() < 768) { 889 headerHeight = $('.fixedHeader').height() + 55 + extraHeightMobile || 0; 890 } 891 $('html, body').animate({ 892 scrollTop: $("#"+anchor).offset().top - headerHeight 893 }, 300, 'swing', function () { 894 history.pushState(null, null, '#' + anchor); 895 lastScrollTop = $(window).scrollTop(); 896 }); 897 } 898 }); 899 900 if ($('#main_table_of_contents').length) { 901 var tocActiveOnScroll = function() { 902 var count = $('.table_of_contents a').length; 903 var activeLink; 904 $('.table_of_contents a').each(function(){ 905 var extraHeight = 100; 906 if (window.innerWidth < 768) { 907 extraHeight = 150; 908 } 909 910 if ($($(this).attr('href')).offset().top < ($(window).scrollTop() + $('#affix').height() + extraHeight)) { 911 activeLink = $(this); 912 } 913 if (!--count && activeLink) { 914 $('.table_of_contents a').removeClass('active'); 915 activeLink.addClass('active'); 916 $('a[href="' + activeLink.attr('href') + '"]').addClass('active'); 917 } 918 }); 919 }; 920 tocActiveOnScroll(); 921 window.addEventListener('scroll', function () { 922 tocActiveOnScroll(); 923 }); 924 } 925 926 let tocVisible = true; 927 let lastScrollTop = $(window).scrollTop(); 928 929 if(window.location.hash && $('#main_table_of_contents').length) { 930 $('.table_of_contents a').each(function() { 931 if (window.location.hash === this.hash) { 932 let headerH = (window.innerWidth > 767) ? 65 : 160; 933 tocVisible = false;
934 $('html, body').animate({ 935 scrollTop: $(window.location.hash).offset().top - headerH + 'px' 936 }, 500, 'swing', function () { 937 tocVisible = true; 938 lastScrollTop = $(window).scrollTop(); 939 }); 940 return false; 941 } 942 }) 943 } 944 945 // Table of contents END 946 947 equalHeightsCMSMerch(); 948 $(window).resize(function () { 949 equalHeightsCMSMerch(); 950 }); 951 952 //CMS page "Our writers" 953 let authorItem = $('#cms #authors-container .author-item'); 954 if (authorItem.length) { 955 authorItem.equalHeights(); 956 $(window).resize(function () { 957 authorItem.equalHeights(); 958 }); 959 } 960 961 equalHeightsProductCardBottom(); 962 963 //cart link 964 $('.shopping_cart > a:not(.dropdown-toggler)').click(function() { 965 var cart_link = $(this).data("link"); 966 if (typeof cart_link !== 'undefined') { 967 $(location).attr('href',cart_link); 968 } 969 }); 970 971 if ($('.info-data .share').length > 1) { 972 $('.info-data .share:first-child').addClass('visible-xs'); 973 $('.info-data .share:not(:first-child)').addClass('hidden-xs'); 974 } 975 976 var authentication_login_button = $('.authentication_login_button'); 977 if(authentication_login_button.length) { 978 authentication_login_button.click(function (e) { 979 e.preventDefault(); 980 const newUrl = $(this).data('href'); 981 if(typeof newUrl !== 'undefined' && newUrl != '') { 982 document.location.replace(newUrl); 983 } 984 }) 985 } 986 987 if ($('#update-infos-form').length !== 0) { 988 $('#months, #years, #days').on('change', function () { 989 const days = $('#days').val(); 990 const months = $('#months').val()-1; 991 const years = $('#years').val(); 992 const now = new Date(); 993 const today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); 994 const birthday = new Date(years, months, days); 995 const birthdaynow = new Date(today.getFullYear(), birthday.getMonth(), birthday.getDate()); 996 var age; 997 age = today.getFullYear() - birthday.getFullYear(); 998 if (today < birthdaynow) { 999 age = age-1; 1000 }
1001 if (age < $('#update-infos-form .date-content').attr('data-adult-age')) { 1002 $('.date .form-error').show(); 1003 $('.form_info button[name="updateInfo"]').attr('disabled', true); 1004 $('.form_info button[name="updateInfo"]').css('opacity', 0.5); 1005 } 1006 else { 1007 $('.date .form-error').hide(); 1008 $('.form_info button[name="updateInfo"]').attr('disabled', false); 1009 $('.form_info button[name="updateInfo"]').css('opacity', 1); 1010 } 1011 }); 1012 } 1013 1014 updateFilterContainerHeight(); 1015 var observer = new MutationObserver(function(mutations) { 1016 mutations.forEach(updateFilterContainerHeight); 1017 }); 1018 1019 var innerContainer = document.querySelector(".fixedHeader"); 1020 if (innerContainer) { 1021 observer.observe(innerContainer, { 1022 attributes: true, 1023 childList: true, 1024 subtree: true, 1025 characterData: true 1026 }); 1027 } 1028 1029 $('.viewcarousel .add-all-button').on('click', function () { 1030 var $carousel = $(this).closest('.viewcarousel'); 1031 var $addButtons = $carousel.find('.add-to-cart-wrap input[type="submit"].ajax_add_to_cart_button'); 1032 $addButtons.each(function () { 1033 $(this).trigger('click'); 1034 }); 1035 }); 1036}); 1037 1038function toggleViewProductsShortcodeFeatures(id) { 1039 const $toggleBtn = $('#features-details-' + id); 1040 const $featuresBlock = $('#features-' + id); 1041 1042 if ($toggleBtn.length && $featuresBlock.length) { 1043 $toggleBtn.toggleClass('open'); 1044 $featuresBlock.toggleClass('open'); 1045 } 1046} 1047 1048function updateFilterContainerHeight() { 1049 var timerBannerMobileWrap = $('.timmer_banner_inner_container'); 1050 var filterContainerMobile = $('#filter-container-mobile'); 1051 if (filterContainerMobile.length) { 1052 if (timerBannerMobileWrap.length && window.innerWidth < 768) { 1053 filterContainerMobile.css('margin-top', timerBannerMobileWrap.outerHeight() + 'px'); 1054 } else { 1055 filterContainerMobile.css('margin-top', '0px'); 1056 } 1057 } 1058} 1059 1060function maskedLinkRedirect(link) { 1061 //redirect to link 1062 document.location.href = link; 1063}; 1064 1065function copyTableOfContents() { 1066 if ($('.table_of_contents_mobile_wrapper').length) { 1067 if ($('#main_table_of_contents').length) { 1068 $('#main_table_of_contents').remove(); 1069 } 1070 let tocCopied = false; 1071 let selector = ''; 1072 for (selector of ['.info_blog', '.info-data', '.static_block_main .accordion-head', '.toc-wrap']) { 1073 if ($(selector).length) { 1074 let newToc = '<div id="main_table_of_contents" class="table_of_contents accordion-wrap">' + $('.table_of_contents').html() + '</div>'; 1075 $(selector).after(newToc); 1076 tocCopied = true; 1077 break; 1078 } 1079 } 1080 } 1081} 1082 1083function initNiceCombinationsSelect() 1084{ 1085 if ($('.combinations-block select').length) { 1086 $('.combinations-block select').selectric( 1087 { 1088 openOnFocus: false, 1089 nativeOnMobile: false, 1090 arrowButtonMarkup: '<b class="button-chevron"><img width="10" src="/themes/responsive/img/chevron-down.svg"></b>', 1091 optionsItemBuilder: function(itemData, element, index) { 1092 let price = itemData.element[0].dataset.tribePoints > 0 ? itemData.element[0].dataset.tribePoints : itemData.element[0].dataset.price; 1093 return '<span>'+itemData.text+'</span>' + '<span>'+price+'</span>'; 1094 } 1095 } 1096 ); 1097 } 1098} 1099 1100function equalHeightsProductCardBottom() { 1101 if ($('.swiper-wrapper').length) { 1102 $('.swiper-wrapper').each(function() { 1103 let bottomLine = $(this).find('.product-item-earn-points'); 1104 if (bottomLine) { 1105 bottomLine.equalHeights(); 1106 } 1107 let combinationsBlock = $(this).find('.combinations-block'); 1108 if (combinationsBlock) { 1109 combinationsBlock.equalHeights(); 1110 } 1111 let ratingsBlock = $(this).find('.ratingsBlock-new'); 1112 if (ratingsBlock) { 1113 ratingsBlock.equalHeights(); 1114 } 1115 }); 1116 } else { 1117 if ($('.top-sellers.main').length) { //different list display logic on best-sales page 1118 $('.top-sellers.main').each(function () { 1119 let productEarnBottom = $(this).find('.product-item-earn-points'); 1120 let combinationsBlock = $(this).find('.combinations-block'); 1121 let ratingsBlock = $(this).find('.ratingsBlock-new'); 1122 processProductCardElementHeight(productEarnBottom); 1123 processProductCardElementHeight(combinationsBlock); 1124 processProductCardElementHeight(ratingsBlock); 1125 }) 1126 } else { 1127 let productEarnBottom = $('.product-item-earn-points'); 1128 let combinationsBlock = $('.combinations-block');
1129 let ratingsBlock = $('.ratingsBlock-new'); 1130 processProductCardElementHeight(productEarnBottom); 1131 processProductCardElementHeight(combinationsBlock); 1132 processProductCardElementHeight(ratingsBlock); 1133 } 1134 } 1135} 1136 1137function processProductCardElementHeight(el) 1138{ 1139 if (el.length) { 1140 let productEarnBottomArr = el.toArray(); 1141 //chunk size correlates with grid column count at .product_list.productCartRedesign.grid-view 1142 let chunkSize = 4; 1143 let algoliaSearchPage = $('form.algoliaSearch').length; 1144 if (algoliaSearchPage) { 1145 chunkSize = 5; // it is different row grid on algolia results search 1146 } 1147 if (window.innerWidth < 1200) { 1148 chunkSize = 3; 1149 } 1150 if (window.innerWidth < 768) { 1151 chunkSize = 2; 1152 } 1153 for (let i = 0; i < productEarnBottomArr.length; i += chunkSize) { 1154 const chunk = productEarnBottomArr.slice(i, i + chunkSize); 1155 var d = $($.map(chunk, function(el){return $.makeArray(el)})); 1156 d.equalHeights(); 1157 if (el.hasClass('combinations-block') || el.hasClass('ratingsBlock-new')) { 1158 let zeroHeight = true; 1159 d.each(function (e) { 1160 if ($(this).height() > 0) { 1161 zeroHeight = false; 1162 } 1163 }) 1164 if (zeroHeight) { 1165 d.each(function (e) { 1166 $(this).css('margin-top', '0') 1167 }) 1168 } 1169 } 1170 } 1171 } 1172} 1173 1174function equalHeightsCMSMerch() { 1175 if ($('.merch_prdName').length) { 1176 $('.merchandise-products').each(function() { 1177 if (window.innerWidth > 480) { 1178 $(this).find('.merch_prdName').equalHeights(); 1179 } else { 1180 $(this).find('.merch_prdName.first_row').equalHeights(); 1181 $(this).find('.merch_prdName.second_row').equalHeights(); 1182 } 1183 }); 1184 } 1185} 1186 1187var alternateHeader = { 1188 $dropdown_toggler_selector: null, 1189 $dropdown_toggler: null, 1190 $dropdown_selector: null, 1191 $dropdown: null, 1192 $dropdown_border: null, 1193 $header_links: null, 1194 $tmcategories: null, 1195 1196 init: function () { 1197 let self = this; 1198 1199 self.$dropdown_toggler_selector = '#header_dropdown_toggler'; 1200 self.$dropdown_toggler = $(self.$dropdown_toggler_selector); 1201 1202 if (self.$dropdown_toggler.length) { 1203 self.$dropdown_selector = '#header_dropdown_wrap'; 1204 self.$dropdown = $(self.$dropdown_selector); 1205 self.$dropdown_border = $('#header_dropdown_toggler_border'); 1206 self.$header_links = $('#header_dropdown_header_links'); 1207 self.$tmcategories = $('#tmcategories'); 1208 1209 self.initActions(); 1210 } 1211 }, 1212 1213 initActions: function () { 1214 let self = this; 1215 const ANIMATE_DURATION = 200; 1216 const ANIMATE_EASING = 'swing'; 1217 $('body').on('click', self.$dropdown_toggler_selector, function() { 1218 self.$dropdown_toggler.toggleClass('opened'); 1219 self.$dropdown_border.toggle(); 1220 self.$dropdown.toggle(); 1221 self.$header_links.toggle(); 1222 if ($('.cat.custommenu').length) { 1223 $('.cat.custommenu > li > a').toggleClass('no-background'); 1224 } 1225 $('.affix').toggleClass('header_dropdown_opened'); 1226 if (self.$dropdown_toggler.hasClass('opened')) { 1227 self.$header_links.prependTo(self.$dropdown); 1228 self.$tmcategories.appendTo(self.$dropdown); 1229 var height = $(window).scrollTop(); 1230 $('.fixedHeader').append('<div id="dummy_tmcategories"></div>'); 1231 let dummy_height = $('#index').length ? '102px' : '122px'; 1232 $('#dummy_tmcategories').css('height', dummy_height) 1233 if (height > 0) { 1234 $('.tp-mobile-wrapper').animate({height: 'auto'}, ANIMATE_DURATION, ANIMATE_EASING); 1235 } 1236 else { 1237 $('.fixedHeader').animate({marginTop: '50px'}, ANIMATE_DURATION, ANIMATE_EASING); 1238 } 1239 } else { 1240 self.$tmcategories.appendTo($('.fixedHeader')); 1241 $('#dummy_tmcategories').remove(); 1242 } 1243 }); 1244 $('body').on('click', function (event) { 1245 if(!$(event.target).closest(self.$dropdown_selector).length && !$(event.target).is(self.$dropdown_toggler_selector)) { 1246 self.hideDropdown(); 1247 } 1248 }); 1249 }, 1250 1251 hideDropdown: function () { 1252 let self = this; 1253 if (self.$dropdown_toggler.hasClass('opened')) { 1254 self.$dropdown.hide(); 1255 self.$tmcategories.appendTo($('.fixedHeader')); 1256 $('#dummy_tmcategories').remove(); 1257 self.$dropdown_toggler.removeClass('opened'); 1258 $('.affix').removeClass('header_dropdown_opened'); 1259 self.$dropdown_border.hide(); 1260 self.$header_links.hide(); 1261 if ($('.cat.custommenu').length) { 1262 $('.cat.custommenu > li > a').removeClass('no-background'); 1263 } 1264 } 1265 } 1266}; 1267 1268$(function () { 1269 if (analyticsCookieEnabledForAlgolia) { 1270 window.algolia = initAlgolia(); 1271 1272 // PLP: Product Clicked 1273 $('#product_list a').on('click mousedown', function (e) { 1274 var product = $(this).closest('.ajax_block_product'); 1275 if (!product.length || !product.data('algolia_item_position')) { 1276 return; 1277 } 1278 1279 if (!(e.type == 'mousedown' && e.which == 2) && !(e.type == 'click')) { // mouse wheel mousedown and click events 1280 return; 1281 } 1282 1283 let type = 'listing'; 1284 if (typeof algolia_category_page !== 'undefined') { 1285 type = 'category_listing'; 1286 } 1287 1288 var data = { 1289 'query_id': $('#product_list').data('algolia_query_id'), 1290 'position': product.data('algolia_item_position'), 1291 'type': type, 1292 }; 1293 algolia.saveEventData(data); 1294 }); 1295 } 1296}); 1297 1298function initAlgolia() { 1299 //var a; 1300 1301 var algolia = { 1302 saveEventData: function (data) { 1303 setCookie('algolia_data', JSON.stringify(data), 1); 1304 } 1305 } 1306 //algolia.init(); 1307 return algolia; 1308} 1309 1310var geoSettingsBlock = { 1311 $blocks: null, 1312 $dropdown: null, 1313 1314 init: function () { 1315 var self = this; 1316 self.$blocks = $('.geo-settings-block'), self.$dropdown = $('#geo-settings-dropdown'); 1317 1318 $('body').click(function (e) { 1319 if ($(e.target).closest('.geo-settings-toggle').length) { 1320 self.toggleDropdown(); 1321 } 1322 else if ($(e.target).closest(self.$dropdown).length) { 1323 if ($(e.target).closest('.closeDropdown').length) { 1324 self.hideDropdown(); 1325 } 1326 } 1327 else { 1328 self.hideDropdown(); 1329 } 1330 }); 1331 1332 $('.change-country').click(function(e) { 1333 e.preventDefault(); 1334 e.stopPropagation(); 1335 self.toggleDropdown(); 1336 $.scrollTo($('body'), 100); 1337 }); 1338 1339 self.setupDropdown(); 1340 $(window).resize(function () { 1341 self.setupDropdown(); 1342 }); 1343 1344 if (self.$dropdown.data('default-open')) { 1345 self.showDropdown(); 1346 } 1347 }, 1348 1349 toggleDropdown: function () { 1350 if (!this.$blocks.hasClass('open')) { 1351 this.showDropdown(); 1352 } 1353 else { 1354 this.hideDropdown(); 1355 } 1356 }, 1357 showDropdown: function () { 1358 this.$blocks.addClass('open'); 1359 this.$dropdown.slideDown(300); 1360 }, 1361 hideDropdown: function () { 1362 this.$blocks.removeClass('open'); 1363 this.$dropdown.slideUp(300); 1364 }, 1365 1366 setupDropdown: function () { 1367 if ($(window).width() > 767 && this.$dropdown.hasClass('mobile')) { 1368 $('#geo-settings-block-desktop').append(this.$dropdown); 1369 this.$dropdown.removeClass('mobile').addClass('desktop'); 1370 } 1371 1372 if ($(window).width() <= 767 && this.$dropdown.hasClass('desktop')) { 1373 $('#geo-settings-block-mobile').append(this.$dropdown); 1374 this.$dropdown.removeClass('desktop').addClass('mobile'); 1375 } 1376 }, 1377}; 1378 1379var wishlist = { 1380 idLang: 1, 1381 container: null, 1382 1383 init: function() { 1384 var self = this; 1385 1386 self.idLang = lang_id || 1; 1387 self.container = $('#wishlist'); 1388 self.miniWishlist = $('#mini_wishlist_link .dropdown-block'); 1389
1390 $('body').delegate('input.add-to-wishlist', 'click', function(e) { 1391 e.preventDefault(); 1392 var container = $(this).closest('.add-to-wishlist-container'); 1393 var idProduct = container.find('.wl_id_product').val(); 1394 var idCombination = container.find('.wl_id_product_attribute').val() || $('#idCombination').val() || 0; 1395 if ($(this).hasClass('in-wishlist')) { 1396 $(this).removeClass('in-wishlist'); 1397 self.deleteProduct($('.wl-product[data-id="'+idProduct+'"]')); 1398 return false; 1399 } 1400 self.addToWL(idProduct, idCombination); 1401 $(this).addClass("in-wishlist"); 1402 return false; 1403 }); 1404 1405 $(document).on('click', '.jsContinueShopping',function (e) { 1406 e.preventDefault(); 1407 $('#fancybox-close').trigger('click'); 1408 }); 1409 1410 $(document).on('click', '.ajax_wishlist_block_remove_link', function(e) { 1411 e.preventDefault(); 1412 self.deleteProduct($(this).closest('.wl-product')); 1413 return false; 1414 }); 1415 1416 $(document).on('submit', ".wishlist-alert-wrapper #login_form", function(e){ 1417 e.preventDefault(); 1418 var self = this; 1419 if (typeof grecaptcha !== 'undefined') { 1420 1421 grecaptcha.execute($("#wishlist-g-recaptcha-key").val(), {action: 'sign_in' }).then(function (token) { 1422 $("#wishlist-g-recaptcha-response").val(token); 1423 self.submit(); 1424 }); 1425 } else { 1426 self.submit(); 1427 } 1428 }); 1429 }, 1430 1431 addToWL: function(idProduct, idProductAttribute) { 1432 var self = this; 1433 1434 if (typeof algolia_query_id !== 'undefined') { 1435 var type = 'listing'; 1436 if (typeof algolia_category_page !== 'undefined' || typeof algolia_query_id_from_category !== 'undefined') { 1437 type = 'category_listing'; 1438 } 1439 if (typeof algolia_autocomplete_search !== 'undefined') { 1440 type = 'autocomplete'; 1441 } 1442 var data = { 1443 'query_id': algolia_query_id, 1444 'type': type, 1445 } 1446 algolia.saveEventData(data); 1447 } 1448 1449 let wishlist_add = false; 1450 if ($('.redeem-slider').length) { 1451 wishlist_add = true; 1452 } 1453 $.ajax({ 1454 type: 'POST', 1455 url: baseDir+'modules/wishlist/ajax.php', 1456 data: 'ajaxAddToWishlist=1&wishlist_add='+wishlist_add+'&id_product=' + idProduct + '&id_product_attribute=' + idProductAttribute + '&id_lang=' + self.idLang + '&uri=' + location.href + '&wishlist_add = '+ wishlist_add + '&token=' + static_token, 1457 dataType: 'json', 1458 success: function(data) { 1459 if (typeof data == 'object') { 1460 if (data.success) { 1461 if (data.miniwishlist_html) { 1462 self.miniWishlist.html(data.miniwishlist_html); 1463 $('.ajax_wishlist_quantity').removeClass('hiddenLight'); 1464 $('.ajax_wishlist_quantity').text(data.wishlist_count); 1465 lazyInstance.addItems('.mini-wishlist-list .lazy'); 1466 lazyInstance.update(); 1467 ajaxCart.overrideButtonsInThePage(); 1468 } 1469 if (data.confirm_popup_html) { 1470 self.showPopup(data.confirm_popup_html); 1471 } 1472 else if (data.auth_popup_html) { 1473 if (typeof data.captcha_key !== 'undefined') { 1474 $.getScript("https://www.google.com/recaptcha/api.js?render=" + data.captcha_key); 1475 } 1476 self.showPopup(data.auth_popup_html); 1477 } 1478 else { 1479 alert('Technical error'); 1480 } 1481 document.dispatchEvent(new CustomEvent('afterAddToWishlist', { 1482 detail: { gaData: data.gaData }, 1483 })); 1484 } 1485 else if (data.error) { 1486 alert('There is 1 error:\n\n' + data.errors[0]); 1487 } 1488 } 1489 else { 1490 alert('Technical error'); 1491 } 1492 }, 1493 error: function(XMLHttpRequest, textStatus, errorThrown) { 1494 alert('Technical error'); 1495 } 1496 }); 1497 }, 1498 1499 showPopup: function(content) { 1500 $.fancybox({ 1501 content: $(content), 1502 'padding': 0, 1503 'margin': 20, 1504 'autoScale': true, 1505 'centerOnScroll': true, 1506 'autoDimensions': true, 1507 'transitionIn': 'none', 1508 'transitionOut': 'none', 1509 onStart: function () { 1510 $('#fancybox-overlay').addClass('wishlist_popup-fancybox-overlay'); 1511 $('#fancybox-wrap').addClass('wishlist_popup'); 1512 }, 1513 onComplete: function() { 1514 resizeFancybox(); 1515 }, 1516 onClosed: function() { 1517 $('#fancybox-overlay').removeClass('wishlist_popup-fancybox-overlay'); 1518 $('#fancybox-wrap').removeClass('wishlist_popup'); 1519 } 1520 }); 1521 }, 1522 1523 deleteProduct: function(product) { 1524 var self = this; 1525 1526 var idProduct = product.data('id'); 1527 1528 $.ajax({ 1529 type: 'POST', 1530 url: baseDir+'modules/wishlist/ajax.php', 1531 data: 'ajaxDeleteProduct=1&id_product=' + idProduct + '&id_lang=' + self.idLang, 1532 dataType: 'json', 1533 success: function(data) { 1534 if (typeof data == 'object') { 1535 if (data.success) { 1536 $('.ajax_wishlist_quantity').text(parseInt($('.ajax_wishlist_quantity').text()) - 1); 1537 1538 product.hide(600).delay(600).queue(function() { 1539 $(this).remove(); 1540 1541 if (data.empty_list_html) { 1542 self.container.append(data.empty_list_html); 1543 } 1544 }); 1545 } 1546 else if (data.error) { 1547 1548 } 1549 } 1550 else { 1551 alert('Technical error'); 1552 } 1553 }, 1554 error: function(XMLHttpRequest, textStatus, errorThrown) { 1555 alert('Technical error'); 1556 } 1557 }); 1558 1559 return false;
1560 } 1561}; 1562 1563var TmCategories = { 1564 /** 1565 * All wrappers in first level of menu. 1566 */ 1567 $topCategories: $('#cat'), 1568 1569 init: function () { 1570 if ($('#cat.custommenu').length) { 1571 return; 1572 } 1573 var self = this; 1574 self.makeColumns($(this)); 1575 }, 1576 1577 makeColumns: function ($wrapper) { 1578 var itemsCount = this.$topCategories.children('li').length; 1579 if (itemsCount) { 1580 this.$topCategories.children('li:nth-child(n+'+(parseInt(itemsCount/2)+2)+')').find('.subcat:first-child>.menu_item_image').each(function () { 1581 $(this).parent().appendTo($(this).parent().parent()); 1582 }); 1583 } 1584 $('.subcategory-wrapper .links-wrapper .subcat').each(function() { 1585 if ($(this).find('.menu_item_image').length) { 1586 var sorted = $(this).find('.menu_item_image').sort(function(a, b) { 1587 return ($(a).data('menu-position')) > ($(b).data('menu-position')) ? 1 : -1; 1588 }); 1589 var result = ''; 1590 sorted.each(function() { 1591 result += $("<div />").append($(this).clone()).html(); 1592 }); 1593 $(this).html(result); 1594 } 1595 }); 1596 } 1597}; 1598 1599 1600 1601function setVideoHeight() { 1602 var ratio = 16/9; 1603 var screen_md_max = 1199; 1604 if ($("iframe[src*='vimeo'],iframe[src*='youtube']").length) { 1605 if (window.outerWidth <= screen_md_max) { 1606 $("iframe[src*='vimeo'],iframe[src*='youtube']").height($("iframe[src*='vimeo'],iframe[src*='youtube']").width() / ratio); 1607 }else { 1608 $("iframe[src*='vimeo'],iframe[src*='youtube']").css('height', ''); 1609 } 1610 } 1611} 1612 1613function adjustPullQuotes() 1614{ 1615 $prevP = $('.related-story-quote').prev(); 1616 $prevP.each(function() { 1617 if ($.trim($(this).text().length) < 1) { 1618 $(this).css('padding-top', '0px'); 1619 } 1620 }); 1621} 1622 1623function fullWidthSupport() 1624{ 1625 $('.full-width').each(function () { 1626 var height = $(this).height(); 1627 $(this).next('.full-width-dummy-height:not(#piscesslider-height)').height(height); 1628 }); 1629} 1630 1631function updateBreadcrumbPosition() 1632{ 1633 $('.breadcrumb_inner').css('left', -1 * $('#right_column').width()); 1634} 1635 1636function positionAffixMenu() 1637{ 1638 if (window.outerWidth >= 768 && $('#header_logo').length) { 1639 var pos = $('#header_logo').offset(); 1640 $('#tmcategories').find('.span-icon').css('left', pos.left + $('#header_logo').width() + 35); 1641 $('#catSmall').css('left', pos.left + $('#header_logo').width() + 35); 1642 } 1643 else { 1644 $('#tmcategories').find('.span-icon').css('left', 0); 1645 $('#catSmall').css('left', 0); 1646 } 1647} 1648 1649function positionAffixToc() 1650{ 1651 if (window.outerWidth >= 768 && $('#header_logo').length) { 1652 var pos = $('#header_logo').offset(); 1653 $('#tmcategories').find('.span-icon').css('left', pos.left + $('#header_logo').width() + 35); 1654 $('#catSmall').css('left', pos.left + $('#header_logo').width() + 35); 1655 } 1656 else { 1657 $('#tmcategories').find('.span-icon').css('left', 0); 1658 $('#catSmall').css('left', 0); 1659 } 1660} 1661 1662function updatePriceAfterQuantity(value) { 1663 value = parseInt(value); 1664 var pointsPrice = $(".points_price .points-num"); 1665 if (pointsPrice) { 1666 pointsPrice.text(pointsPrice.data('points-price') * value); 1667 } 1668 if(qd_quantity_discounts) { 1669 var old_price = parseFloat(productPriceWithoutRedutionAndQuantity); 1670 var current_price = parseFloat(productPriceWithoutQuantity); 1671 var new_price = false; 1672 var new_int_price = 0; 1673 var new_fract_price = 0; 1674 var old_int_price = 0; 1675 var old_fract_price = 0; 1676 1677 var separator = ','; 1678 var separator_thousands = '.'; 1679 if (typeof currencyFormat !== 'undefined') { 1680 if (currencyFormat == 1 || currencyFormat == 4) { 1681 separator = '.'; 1682 separator_thousands = ','; 1683 } else if (currencyFormat == 2) { 1684 separator_thousands = ' '; 1685 } else if (currencyFormat == 6) { 1686 separator_thousands = ''; 1687 } 1688 } 1689 for(var key in qd_quantity_discounts){ 1690 if(value >= key) { 1691 new_price = current_price - (current_price * parseFloat(qd_quantity_discounts[key])); 1692 } 1693 } 1694 if(new_price) { 1695 new_price = Math.ceil((new_price)*100)/100; 1696 new_price = new_price.toString(); 1697 new_int_price = new_price.split('.')[0]; 1698 new_fract_price = new_price.split('.')[1]; 1699 if(typeof new_fract_price == "undefined" ) { 1700 new_fract_price = "00"; 1701 } 1702 else { 1703 new_fract_price = new_fract_price.padEnd(2,'0'); 1704 }
1705 old_price = Math.ceil((old_price)*100)/100; 1706 old_price = old_price.toString(); 1707 old_int_price = old_price.split('.')[0]; 1708 old_fract_price = old_price.split('.')[1]; 1709 if(typeof old_fract_price == "undefined" ) { 1710 old_fract_price = "00"; 1711 } 1712 else { 1713 old_fract_price = old_fract_price.padEnd(2,'0'); 1714 } 1715 $("#old_int_price").text(formatNumber(old_int_price, 0, separator_thousands, '') + (priceDisplayPrecision ? separator : '')); 1716 $("#old_fract_price").text(priceDisplayPrecision ? old_fract_price : ''); 1717 $("#old_price").show(); 1718 $("#our_int_price").text(formatNumber(new_int_price, 0, separator_thousands, '') + (priceDisplayPrecision ? separator : '')); 1719 $("#our_fract_price").text(priceDisplayPrecision ? new_fract_price : '' ); 1720 } 1721 else { 1722 if(old_price === current_price){ 1723 $("#old_price").hide(); 1724 new_price = Math.ceil((current_price)*100)/100; 1725 new_price = new_price.toString(); 1726 new_int_price = new_price.split('.')[0]; 1727 new_fract_price = new_price.split('.')[1]; 1728 if(typeof new_fract_price == "undefined" ) { 1729 new_fract_price = "00"; 1730 } 1731 else { 1732 new_fract_price = new_fract_price.padEnd(2,'0'); 1733 } 1734 $("#our_int_price").text(formatNumber(new_int_price, 0, separator_thousands, '') + (priceDisplayPrecision ? separator : '')); 1735 $("#our_fract_price").text(priceDisplayPrecision ? new_fract_price : ''); 1736 } 1737 else { 1738 old_price = Math.ceil((old_price)*100)/100; 1739 old_price = old_price.toString(); 1740 old_int_price = old_price.split('.')[0]; 1741 old_fract_price = old_price.split('.')[1]; 1742 if(typeof old_fract_price == "undefined" ) { 1743 old_fract_price = "00"; 1744 } 1745 else { 1746 old_fract_price = old_fract_price.padEnd(2,'0'); 1747 } 1748 $("#old_int_price").text(formatNumber(old_int_price, 0, separator_thousands, '') + (priceDisplayPrecision ? separator : '')); 1749 $("#old_fract_price").text(priceDisplayPrecision ? old_fract_price : ''); 1750 $("#old_price").show(); 1751 new_price = Math.ceil((current_price)*100)/100; 1752 new_price = new_price.toString(); 1753 new_int_price = new_price.split('.')[0]; 1754 new_fract_price = new_price.split('.')[1]; 1755 if(typeof new_fract_price == "undefined" ) { 1756 new_fract_price = "00"; 1757 } 1758 else { 1759 new_fract_price = new_fract_price.padEnd(2,'0'); 1760 } 1761 $("#our_int_price").text(formatNumber(new_int_price, 0, separator_thousands, '') + (priceDisplayPrecision ? separator : '')); 1762 $("#our_fract_price").text(priceDisplayPrecision ? new_fract_price : ''); 1763 } 1764 } 1765 } 1766} 1767 1768function uploadVideos() { 1769// start upload Youtube-Vimeo videos after img click 1770 1771 var ytvideos = document.querySelectorAll('[data-name="youtube"]'); 1772 1773 //for youtube loop 1774 1775 for (var i = 0; i < ytvideos.length; i++) { 1776 1777 // Get Youtube thumbnail image source. 1778 var source = 'https://img.youtube.com/vi/'+ ytvideos[i].dataset.embed +'/sddefault.jpg'; 1779 1780 // Load the image asynchronously 1781 var image = new Image(); 1782 image.src = source; 1783 image.addEventListener('load', function() { 1784 if (image.naturalWidth <= 120) { // thumbnail not exist 1785 image.src = image.src.replace('sddefault.jpg', 'hqdefault.jpg'); 1786 } 1787 var play_button = ytvideos[i].querySelector('.play-button'); 1788 var temp_id = ytvideos[i].querySelector('.temp_id'); 1789 if (temp_id !== null) { 1790 play_button.removeChild(temp_id); 1791 } 1792 ytvideos[i].appendChild( image ); 1793 }(i)); 1794 1795 // When clicking video load iframe 1796 addClickOnYoutube(ytvideos[i]); 1797 }// end youtube loop 1798 1799 var xhr = []; 1800 var sourceb; 1801 var vimeovideos = document.querySelectorAll('[data-name="vimeo"]'); 1802 1803 //for vimeo loop 1804 for(b = 0; b < vimeovideos.length; b++) { 1805 1806 (function (b) { 1807 // Get Vimeo thumbnail images source from XML file 1808 xhr[b] = new XMLHttpRequest; 1809 xhr[b].open('GET', 'https://vimeo.com/api/v2/video/' + vimeovideos[b].dataset.embed + '.json'); 1810 1811 // If specified, responseType must be empty string or "document" 1812 xhr[b].responseType = 'json'; 1813 1814 xhr[b].multipart = true; 1815 1816 // Force the response to be parsed as XML 1817 xhr[b].overrideMimeType('text/xml'); 1818 1819 xhr[b].onload = function () { 1820 1821 if (xhr[b].readyState === xhr[b].DONE && xhr[b].status === 200) { 1822
1823 // Get URL from image inside XML 1824 sourceb = xhr[b].response[0].thumbnail_large; 1825 1826 var imageb = new Image(); 1827 imageb.addEventListener('load', function () { 1828 var play_button = vimeovideos[b].querySelector('.play-button'); 1829 var temp_id = vimeovideos[b].querySelector('.temp_id'); 1830 if (temp_id !== null) { 1831 play_button.removeChild(temp_id); 1832 } 1833 vimeovideos[b].appendChild(imageb); 1834 }(b)); 1835 1836 // Load the image asynchronously 1837 imageb.src = sourceb; 1838 1839 // store src of image to get it later after fancybox inline reinstall 1840 vimeovideos[b].setAttribute('stored_src', sourceb); 1841 1842 // When clicking video load iframe 1843 addClickOnVimeo(vimeovideos[b]); 1844 } 1845 }; 1846 xhr[b].send(); 1847 })(b); 1848 } 1849} 1850 1851function addClickOnYoutube(el) { 1852 el.addEventListener('click', function() { 1853 1854 var iframe = document.createElement( "iframe" ); 1855 1856 iframe.setAttribute( 'allow', 'autoplay'); 1857 iframe.setAttribute( 'frameborder', '0'); 1858 iframe.setAttribute( 'allowfullscreen', ''); 1859 iframe.setAttribute( 'src', 'https://www.youtube.com/embed/'+ this.dataset.embed +'?rel=0&showinfo=0&autoplay=1&mute=0'); 1860 iframe.setAttribute( 'title', this.dataset.title); 1861 1862 this.innerHTML = ''; 1863 this.appendChild( iframe ); 1864 }); 1865} 1866 1867function addClickOnVimeo(el) { 1868 el.addEventListener('click', function () { 1869 1870 var iframe = document.createElement('iframe'); 1871 1872 iframe.setAttribute('frameborder', '0'); 1873 iframe.setAttribute('allowfullscreen', ''); 1874 iframe.setAttribute('allow', 'autoplay'); 1875 iframe.setAttribute('src', 'https://player.vimeo.com/video/' + this.dataset.embed + '?autoplay=1&color=ff0179&portrait=0'); 1876 iframe.setAttribute( 'title', this.dataset.title); 1877 1878 this.innerHTML = ''; 1879 this.appendChild(iframe); 1880 }); 1881} 1882 1883var onloadCaptcha = function () { 1884 if (typeof recaptcha_key == 'undefined' && typeof recaptcha_page == 'undefined') { 1885 return; 1886 } 1887 1888 if (recaptcha_page == 'order' 1889 || recaptcha_page == 'authentication' 1890 || recaptcha_page == 'contact' 1891 || recaptcha_page == 'password_recovery' 1892 || recaptcha_page == 'identity' 1893 || recaptcha_page == 'win' 1894 || recaptcha_page == 'contest' 1895 ) { 1896 $('#voucher, #login_form, #recover_password, #account-creation_form, #giftCard, #contact_us, #update-infos-form, #winForm').on('submit', function(e) { 1897 if (typeof(executeCaptcha) !== "undefined" && !$('#g-recaptcha-response').val()) { 1898 e.preventDefault(); 1899 executeCaptcha(); //async function 1900 } 1901 }); 1902 } else { 1903 executeCaptcha(); 1904 } 1905} 1906 1907function executeCaptcha() { 1908 grecaptcha.ready(function () { 1909 grecaptcha.execute(recaptcha_key, {action: recaptcha_page }).then(function (token) { 1910 1911 $("#g-recaptcha-response").val(token); 1912 1913 if (recaptcha_page == 'order') { 1914 $("#voucher, #giftCard").submit(); 1915 } 1916 1917 if (recaptcha_page == 'authentication' || recaptcha_page == 'contest') { 1918 if ($('#account-creation_form').length) { 1919 $('#submitAccount').click(); 1920 } 1921 1922 if ($('#login_form').length) { 1923 $('#SubmitLogin').click(); 1924 } 1925 } 1926 1927 if (recaptcha_page == 'password_recovery') { 1928 $('#SubmitPassword').click(); 1929 } 1930 1931 if (recaptcha_page == 'contact') { 1932 $("#contact_us").submit(); 1933 } 1934 1935 if (recaptcha_page == 'identity') { 1936 $("#update-infos-form").submit(); 1937 } 1938 1939 if (recaptcha_page == 'win') { 1940 $("#winForm").submit(); 1941 } 1942 1943 if (recaptcha_page == 'kratomcalculator') { 1944 calculateKratom(); 1945 } 1946 }); 1947 }); 1948} 1949 1950function displayProductsRating() { 1951 $('#product_list .gsrDisplayRating, #product_comparison .gsrDisplayRating').each(function(){ 1952 var checkbox = $(this).find('.star:visible'); 1953 jQuery(checkbox).rating({ 1954 half: !!$(this).data('half'), 1955 starGif: $(this).data('star-gif'), 1956 starWidth: $(this).data('starWidth'), 1957 readOnly : true, 1958 }); 1959 }); 1960} 1961 1962(function () { 1963 if ('fonts' in document) { 1964 document.fonts.load('1em Oswald').then(function () { 1965 $('.banner-container .content-container').show(); 1966 }); 1967 } else { 1968 $('.banner-container .content-container').show(); 1969 } 1970})(); 1971 1972function initAjaxPagination() { 1973 $('.view-more-button-container').show(); 1974 1975 if (!($('#pagination_next').length) || $('#pagination_next').hasClass('disabled') || "undefined" == typeof(InfiniteScroll) || "object" == typeof(mobileFilter)) { 1976 return; 1977 } 1978 var pathBlock = $('ul.pagination li:last a'); 1979 productListContainer = new InfiniteScroll('#product_list', { 1980 navSelector : '#pagination', 1981 nextSelector : 'ul.pagination li:last a', 1982 itemSelector : '.product_list .ajax_block_product', 1983 append: '#product_list .ajax_block_product', 1984 loadOnScroll: false, 1985 history: false, 1986 path: function() { 1987 var path = ''; 1988 if ($('.product_list .ajax_block_product').length + ((products_on_page * page_number) - products_on_page) < nb_products && pathBlock.length) { 1989 var baseHref = pathBlock.attr('href') || pathBlock.attr('data-href'); 1990 if (baseHref) { 1991 path = baseHref.replace(/p=\d*/, "p=" + (page_number + this.pageIndex)); 1992 } 1993 } 1994 $('.gsrDisplayRating').each(function(){ 1995 var params = { 1996 readOnly: true, 1997 ratingField : "iRating", 1998 starGif: "/modules/gsnippetsreviews/img/hook/star.gif", 1999 starWidth: $(this).data('star-width') 2000 }; 2001 if ('undefined'!=typeof($(this).data('half')) && 1 == $(this).data('half')) { 2002 params['half'] = true; 2003 params['split'] = 2; 2004 } 2005 2006 $(this).find('.star:visible').rating(params); 2007 }); 2008 2009 var viewed = Math.min((page_number + this.pageIndex - 1) * products_on_page, nb_products); 2010 $('.page-progress .load').text(viewed); 2011 $('.page-progress .bar .done').width(Math.ceil(viewed * 100 / nb_products)+'%'); 2012 if (viewed == nb_products) { 2013 $('.view-more-button').hide(); 2014 } 2015 return path; 2016 } 2017 }); 2018 let scrollpos; 2019 $('.view-more-button').on( 'click', function(e) { 2020 e.preventDefault(); 2021 scrollpos = window.scrollY; 2022 productListContainer.loadNextPage(); 2023 $(this).addClass('loading'); 2024 }); 2025 productListContainer.on('append', function() { 2026 $('.lazy').Lazy({chainable: false}); 2027 window.scrollTo(0, scrollpos);//prevent autoscroll 2028 $('.view-more-button').removeClass('loading'); 2029 ajaxCart.overrideButtonsInThePage(); 2030 equalHeightsProductCardBottom(); 2031 }); 2032} 2033 2034(function () { 2035 "use strict"; 2036 2037 function loadScript(src) { 2038 return new Promise(function (resolve, reject) { 2039 var s = document.createElement("script"); 2040 s.src = src; 2041 s.async = true; 2042 s.crossOrigin = "anonymous"; 2043 s.onload = resolve; 2044 s.onerror = reject; 2045 document.head.appendChild(s); 2046 }); 2047 } 2048 2049 function schedule(fn) { 2050 if (typeof window.requestIdleCallback == "function") { 2051 return window.requestIdleCallback(fn, { timeout: 3000 }); 2052 } 2053 return window.setTimeout(fn, 1500); 2054 } 2055 2056 function hasLottieHomeBanner() { 2057 var marker = document.querySelector('meta[name="zam-has-lottie-home-banner"]'); 2058 return marker && marker.getAttribute("content") == "1"; 2059 } 2060 2061 function initDelayedLottie() { 2062 if (!hasLottieHomeBanner()) return; 2063 2064 var LOTTIE_INTERACTIVITY = "https://cdn.jsdelivr.net/npm/@lottiefiles/[email protected]/dist/lottie-interactivity.min.js"; 2065 2066 function bootLottie() { 2067 if (window.__zamLottieBooted) return; 2068 window.__zamLottieBooted = true; 2069 loadScript(LOTTIE_INTERACTIVITY) 2070 .then(function () { 2071 try { 2072 window.dispatchEvent(new CustomEvent("zam:lottie-interactivity-ready")); 2073 } catch (e) {} 2074 }) 2075 .catch(function () {}); 2076 } 2077 2078 if (document.readyState == "complete") { 2079 schedule(bootLottie); 2080 } else { 2081 window.addEventListener("load", function () { 2082 schedule(bootLottie); 2083 }, { once: true, passive: true }); 2084 } 2085 } 2086 2087 initDelayedLottie(); 2088})();
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.