Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
14 kB
5
Indexable
Never
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    /* all Pure helper functions */
    function waitForElement(selector, trigger, delayInterval, delayTimeout) {
      var interval = setInterval(function () {
        if (
          document &&
          document.querySelector(selector) &&
          document.querySelectorAll(selector).length > 0
        ) {
          clearInterval(interval);
          trigger();
        }
      }, delayInterval);
      setTimeout(function () {
        clearInterval(interval);
      }, delayTimeout);
    }
    /* Variation Init */
    function init() {
      document.querySelector('body').classList.add('eg-hero');
      if (document.querySelectorAll('.b-f-product-overview.c-product-overview.component .c-product-image-gallery .product-image-slider.slick-initialized.slick-slider .slick-slide:not(.slick-cloned) > div').length <= 3) {
        if (window.innerWidth > 767) {
          var divforimages = document.createElement('div');
          divforimages.classList.add('wrappperforimages');
          document.querySelector('.col-12.col-md-6.col-xl-5 .c-product-image-gallery').before(divforimages);
          document.querySelectorAll('.b-f-product-overview.c-product-overview.component .c-product-image-gallery .product-image-slider.slick-initialized.slick-slider .slick-slide:not(.slick-cloned) > div').forEach((ele, i) => {
              const clonenode = ele.cloneNode(true);
              document.querySelector('.wrappperforimages').append(clonenode)
          });	
        }
        document.querySelector('.c-product-description').after(document.querySelector('div#accordion').closest('section'));
        document.querySelector('.c-product-description + section.layout-section .col-12.col-md-6:nth-child(2)').classList.remove('col-md-6');
        if(window.innerWidth < 768) {
        document.querySelector('div#accordion .col-12 button#toggle-collapse-pdp-0').classList.add('collapsed');
        document.querySelector('div#accordion .col-12 div#collapsible-pdp-0').classList.remove('show');	
        }
        if(window.innerWidth > 767) {
        document.querySelector('div#accordion .col-12 button#toggle-collapse-pdp-0').click();	
        }
        if (document.querySelector('.c-product-description').textContent.trim().length > 0) {
          const cloneforfeature = document.querySelector('.col-12.c-product-features-specifications__wrapper:nth-child(2)').cloneNode('true');
          document.querySelector('div#accordion .col-12 .row').prepend(cloneforfeature);
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button h4.collapse-toggle-title').textContent = 'Description';
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div div').textContent = document.querySelector('.c-product-description').textContent.trim();
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').classList.remove('collapsed');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').classList.add('show');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('id','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('id','desc-toggle-collapse-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('data-target','#desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('aria-controls','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('id','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('aria-labelledby','desc-toggle-collapse-pdp-0');
        }
        document.querySelectorAll('.wrappperforimages > div').forEach((ele,i) => {
              ele.addEventListener('click', () => {
                const index = [...ele.parentNode.children].indexOf(ele);
                console.log(index);
                wait(() => document.querySelectorAll('.c-lightbox.modal.show').length>0 ,() => {
                  setTimeout(function(){
                      document.querySelectorAll('div#lightboxModal .slider-thumbnails.slick-vertical.slick-initialized.slick-slider .slick-list.draggable .slick-track .slick-slide>div>div')[index].click();
                  },500);
                });
              });
        });
        window.addEventListener('scroll', (data) => {
            const heightofdesc = document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').offsetHeight;
        const heightofimages = document.querySelector('.wrappperforimages').offsetHeight;
            if (window.scrollY > 80 && (window.scrollY < heightofimages + 300)) {
             document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').classList.add('stickyafterscroll')   
            } else {
                document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').classList.remove('stickyafterscroll')   
            }
        });
      }
      if (document.querySelectorAll('.b-f-product-overview.c-product-overview.component .c-product-image-gallery .product-image-slider.slick-initialized.slick-slider .slick-slide:not(.slick-cloned) > div').length > 3) {
        if(window.innerWidth > 767) {
          var divforimages = document.createElement('div');
          divforimages.classList.add('wrappperforimages_4');
          document.querySelector('.col-12.col-md-6.col-xl-5 .c-product-image-gallery').before(divforimages);
          document.querySelectorAll('.b-f-product-overview.c-product-overview.component .c-product-image-gallery .product-image-slider.slick-initialized.slick-slider .slick-slide:not(.slick-cloned) > div').forEach((ele, i) => {
              const clonenode = ele.cloneNode(true);
              document.querySelector('.wrappperforimages_4').append(clonenode)
          });
        }
        document.querySelector('.c-product-description').after(document.querySelector('div#accordion').closest('section'));
        document.querySelector('.c-product-description + section.layout-section .col-12.col-md-6:nth-child(2)').classList.remove('col-md-6');
        if(window.innerWidth < 768) {
        document.querySelector('div#accordion .col-12 button#toggle-collapse-pdp-0').classList.add('collapsed');
        document.querySelector('div#accordion .col-12 div#collapsible-pdp-0').classList.remove('show');	
        }
        if(window.innerWidth > 767) {
        document.querySelector('div#accordion .col-12 button#toggle-collapse-pdp-0').click();	
        }
        if (document.querySelector('.c-product-description').textContent.trim().length > 0) {
          const cloneforfeature = document.querySelector('.col-12.c-product-features-specifications__wrapper:nth-child(2)').cloneNode('true');
          document.querySelector('div#accordion .col-12 .row').prepend(cloneforfeature);
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button h4.collapse-toggle-title').textContent = 'Description';
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div div').textContent = document.querySelector('.c-product-description').textContent.trim();
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').classList.remove('collapsed');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').classList.add('show');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('id','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('id','desc-toggle-collapse-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('data-target','#desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper button').setAttribute('aria-controls','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('id','desc-collapsible-pdp-0');
          document.querySelector('div#accordion .col-12 .row .col-12.c-product-features-specifications__wrapper div').setAttribute('aria-labelledby','desc-toggle-collapse-pdp-0');
      
        }
        document.querySelectorAll('.wrappperforimages_4 > div').forEach((ele,i) => {
              ele.addEventListener('click', () => {
                const index = [...ele.parentNode.children].indexOf(ele);
                console.log(index);
                wait(() => document.querySelectorAll('.c-lightbox.modal.show').length>0 ,() => {
                  setTimeout(function(){
                      document.querySelectorAll('div#lightboxModal .slider-thumbnails.slick-vertical.slick-initialized.slick-slider .slick-list.draggable .slick-track .slick-slide>div>div')[index].click();
                  },500);
                });
              });
        });
        window.addEventListener('scroll', (data) => {
            const heightofdesc = document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').offsetHeight;
        const heightofimages = document.querySelector('.wrappperforimages_4').offsetHeight;
            if (window.scrollY > 80 && (window.scrollY < heightofimages + 300)) {
             document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').classList.add('stickyafterscroll')   
            } else {
                document.querySelector('.b-f-product-detail-main-info.c-product-detail-main-info').classList.remove('stickyafterscroll')   
            }
        });
      }
    }
    /* Initialize variation */
    waitForElement(".b-f-product-overview.c-product-overview.component .c-product-image-gallery .product-image-slider.slick-initialized.slick-slider .slick-slide:not(.slick-cloned) > div", init, 50, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();



body.eg-hero .wrappperforimages + div.c-product-image-gallery {
    display: none;
}
body.eg-hero .wrappperforimages > div {
    cursor: pointer;
}

body.eg-hero .wrappperforimages .slide-item.video figure figure.c-video-image-gallery {
    display: none;
}
body.eg-hero .wrappperforimages .slide-item.video figure.c-video-image-gallery {
    display: none;
}
body.eg-hero .wrappperforimages .slide-item.video figure.c-video-image-gallery {
    margin: 0px;
}

body.eg-hero .wrappperforimages .slide-item.video figure.c-video-image-gallery .wrapper {
    position: unset;
    transform: translate(0px);
}
body.eg-hero .b-f-product-detail-main-info.c-product-detail-main-info.stickyafterscroll {
    position: sticky;
    top: 100px;
}
body.eg-hero .wrappperforimages .slide-item.video:after {
    content: "";
    font-family: "Vita-iconfont";
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 40px;
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    display:block;
}
body.eg-hero .wrappperforimages .slide-item.video {
	position: relative;
}

body.eg-hero .wrappperforimages_4 > div {
    width: 48%;
    margin: 1%;
    cursor: pointer;
}

body.eg-hero .wrappperforimages_4 {
    display: flex;
    flex-wrap: wrap;
}
body.eg-hero .wrappperforimages_4 + div.c-product-image-gallery {
    display: none;
}

body.eg-hero .wrappperforimages_4 .slide-item.video figure.c-video-image-gallery {
    display: none;
}

body.eg-hero .wrappperforimages_4 .slide-item.video figure.c-video-image-gallery {
    margin: 0px;
}

.wrappperforimages_4 .slide-item.video figure.c-video-image-gallery .wrapper {
    position: unset;
    transform: translate(0px);
}
body.eg-hero .b-f-product-detail-main-info.c-product-detail-main-info.stickyafterscroll {
    position: sticky;
    top: 100px;
}

body.eg-hero .c-product-description {
    display: none;
}

body.eg-hero .c-product-description + section.layout-section .col-12.col-md-6:nth-child(1) {
    display: none;
}

body.eg-hero .c-product-description + section.layout-section .component.c-product-features-specifications {
    padding: 1em 0;
    text-align: left;
}
body.eg-hero .c-product-description + section.layout-section > .component.c-product-features-specifications > .container {
    padding: 0px;
}

body.eg-hero .wrappperforimages_4 .slide-item.video:after {
    content: "";
    font-family: "Vita-iconfont";
    speak: none;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 40px;
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate3d(-50%, -50%, 0);
    display:block;
}
body.eg-hero .wrappperforimages_4 .slide-item.video {
	position: relative;
}