Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
12 kB
1
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);
    }

      var arrow = `<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8" fill="none">
      <path fill-rule="evenodd" clip-rule="evenodd" d="M1.22644 1.94994L4.00394 4.60162L6.78144 1.94994C7.06069 1.68335 7.51169 1.68335 7.79094 1.94994C8.07019 2.21653 8.07019 2.64709 7.79094 2.91342L4.50494 6.05006C4.22569 6.31665 3.77469 6.31665 3.49544 6.05006L0.209438 2.91342C-0.0698125 2.64683 -0.0698125 2.21627 0.209438 1.94994C0.488688 1.69031 0.946687 1.68335 1.22594 1.94994H1.22644Z" fill="black"/>
      </svg>`;

      var seeAllLink = `<div class="eg-link enhanced-nav-shop-all text-lg-center d-none d-lg-block">
      <a href="/yankee-shopbyfragrance.html" class="dropdown-link btn-link text14-14-16">See All &nbsp;<span class="fa icon-next" aria-hidden="true"></span></a>
    </div>`;
    
    var shopAllLink = `<div class="eg-link enhanced-nav-shop-all text-lg-center d-none d-lg-block">
    <a href="/yankee-candle/sale/" class="dropdown-link btn-link text14-14-16">Shop All Sale &nbsp;<span class="fa icon-next" aria-hidden="true"></span></a>
    </div>`;

    function init2() {

      var insertInterval = setInterval(function () {

        if(!document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link svg')){
          var egPayments = document.querySelectorAll('nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link');

          for (var i = 0; i < egPayments.length; i++) {
            var egPayment = egPayments[i];
            var egPaymentText = egPayment.innerHTML;
            var egPaymentDetail =  egPaymentText + arrow;
            egPayment.innerHTML = egPaymentDetail;
          }
  
        }
  
    }, 20);

    setTimeout(function () {
      clearInterval(insertInterval);
    }, 8000);

    setTimeout(function () {
      document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block #menu-yankeecandle-shopbyfragrance').insertAdjacentHTML('beforeend', seeAllLink);

      document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block #menu-yankeecandle-sale').insertAdjacentHTML('beforeend', shopAllLink);
  
    }, 2000);



    function init() {

      // var egBackground = document.querySelectorAll('nav .navbar-nav > .nav-item.dropdown.d-lg-block > .menu-link-content > .enhanced-nav');

      // for (i = 0; i < egBackground.length; i++) {
      //   egBackground[i].insertAdjacentHTML('afterend', '<div class="eg-content-bg"></div>');
      // }

      var egNav = document.querySelectorAll('nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link[href]');
      egNav.forEach(function (val) {
        val.parentElement.addEventListener('mouseover', function (e) {
          console.log('init0');
         // e.preventDefault();
          //e.stopImmediatePropagation();
          //e.stopPropagation();
        });
        val.addEventListener('click', function () {
          var self = this;
          document.querySelectorAll('nav .navbar-nav > .nav-item.dropdown.d-lg-block').forEach(function(item, index) {
            if(item != self.parentElement) {
              item.classList.remove('eg-active');
              document.body.classList.remove('eg-menu-open');
            }
          })
          this.parentElement.classList.toggle('eg-active');
          document.body.classList.toggle('eg-menu-open');
          if(this.parentElement.classList.contains('eg-active')) {
            this.parentElement.querySelector('.eg-content-bg') && this.parentElement.querySelector('.eg-content-bg').remove();
            this.parentElement.querySelector('.menu-link-content > .enhanced-nav').insertAdjacentHTML('afterend', '<div class="eg-content-bg"></div>');
          } else {
            document.body.classList.remove('eg-menu-open');
          }
          if(this.parentElement.querySelector('.eg-content-bg')) {
            setTimeout(function() {
              self.parentElement.querySelector('.eg-content-bg').style.height = self.parentElement.querySelector('.menu-link-content .enhanced-nav').clientHeight + 'px';
              console.log(self.parentElement.querySelector('.eg-content-bg'), ' >>>>> ' , self.parentElement.querySelector('.menu-link-content').clientHeight);
            }, 50);
          }
        });
        val.removeAttribute('href');
      });

      document.body.insertAdjacentHTML('beforeend', '<div class=" eg-overlay"><div class="underlay-menu"></div></div>');
      document.querySelector('.eg-overlay').addEventListener('click', function() {
        document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active') && document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active').classList.remove('eg-active');
        document.body.classList.remove('eg-menu-open');
      })
      // document.querySelectorAll('header .home-banner > .header-banner, header .home-banner > .header-row-brands, header .home-banner > .header').forEach(function(item) {
      //   item.addEventListener('click', function() {
      //     console.log('clicked >>>>')
          // document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active') && document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active').classList.remove('eg-active');
          // document.body.classList.remove('eg-menu-open');
      //   })
      // })
      document.querySelector('header .home-banner').addEventListener('click', function(e) {
        if(!e.target.closest('.home-banner > .main-menu')) {
          document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active') && document.querySelector('nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active').classList.remove('eg-active');
          document.body.classList.remove('eg-menu-open');
        }
      })
    }
    /* Initialise variation */
    waitForElement('nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link[href]', init, 100, 25000);

    }
    /* Initialise variation */
    waitForElement("nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link", init2, 100, 25000);

  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();


@media (min-width: 992px){
nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link svg{
    margin-left: 5px;
}
nav .navbar-nav > .nav-item.dropdown.d-lg-block:hover > .nav-link svg path,
nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active > .nav-link svg path {
    fill: #ffffff;
}
nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active > .nav-link svg {
    transform: rotate(180deg);
}

nav .navbar-nav > .nav-item.dropdown.d-lg-block #menu-yankeecandle-sale,
nav .navbar-nav > .nav-item.dropdown.d-lg-block #menu-yankeecandle-shopbyfragrance{
    flex-direction: column;
    justify-content: flex-start;
}
.eg-link .icon-next::before {
    content: '\F105';
}
.eg-link {
    padding-bottom: 20px;
}
nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active > .nav-link svg path {
    fill: #ffffff;
}
}


@media (min-width: 992px){
    .eg-menu-open header.sticky-nav-desktop .main-menu.menu-toggleable-left.navbar-toggleable-lg {
        display: block !important;
    }
    .eg-menu-open header.sticky-nav-desktop .main-menu.menu-toggleable-left.navbar-toggleable-lg,
    .eg-menu-open header.sticky-nav-desktop .navbar.bg-inverse .navbar-nav {
        height: 2.5rem;
    }
    body.eg-menu-open.sticky-nav-desktop .eg-overlay{
        top: 0;
    }
    .eg-menu-open .eg-overlay, .eg-overlay .underlay {
        position: absolute;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        text-align: center;
    }
    .eg-menu-open .eg-overlay .underlay-menu {
        opacity: .4;
        position: absolute;
        background-color: #000;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        text-align: center;
    }
    
    body:not(.eg-menu-open) .searchOverlay.menu.eg-overlay,
    .searchOverlay.menu:not(.eg-overlay),
    html body .main-menu.menu-toggleable-left .navbar-nav .menu-content.show{
        display: none !important;
    }
    
    .eg-menu-open .searchOverlay.menu.eg-overlay{
        display: block !important;
    }
    nav .navbar-nav > .nav-item.dropdown.d-lg-block.eg-active .menu-content{
        display: -webkit-box !important;
        display: -ms-flexbox !important;
        display: flex !important;
        -webkit-box-pack: end !important;
        -ms-flex-pack: end !important;
        justify-content: flex-end !important;
    }
    nav .navbar-nav #menu-yankeecandle-discover-yankee-candle,
    nav .navbar-nav #menu-yankeecandle-sale,
    nav .navbar-nav #menu-yankeecandle-shopbyfragrance{
        width: 663.891px !important;
        max-width: 663.891px !important;   
    }
    .eg-menu-open .main-menu .navbar-nav .eg-active .menu-content .menu-content-bg{
        width: 100vw !important;
        height: 100% !important;
        background: #ffffff !important;
        -webkit-box-shadow: 0 0.3125rem 0.625rem -0.375rem rgba(0,0,0,.5);
        box-shadow: 0 0.3125rem 0.625rem -0.375rem rgba(0,0,0,.5);
        display: block;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        width: 100vw;
        -webkit-transform: translate3d(-50%,0,0);
        transform: translate3d(-50%,0,0);
        background-color: #fff;
    }
    
    .eg-active > a {
        color: #ffffff !important;
        background-image: linear-gradient(to bottom,#2e3a3f,#2e3a3f) !important;
    }
    body.eg-menu-open {
        position: relative;
    }
    nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link{
        cursor: pointer;
        padding: 0.5625rem .8rem !important;
    }
    .eg-active .menu-content-bg,
    .eg-active .dropdown-menu {
        display: block !important;
    }
    
    .menu-content-bg.show{
        display: none !important;
    }
    /* .eg-active .menu-content-bg{
        max-height: 270.031px;
        height: 270px;
    } */
    
    .eg-content-bg{
        -webkit-box-shadow: 0 0.3125rem 0.625rem -0.375rem rgba(0,0,0,.5);
        box-shadow: 0 0.3125rem 0.625rem -0.375rem rgba(0,0,0,.5);
        display: block;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        width: 100vw;
        -webkit-transform: translate3d(-50%,0,0);
        transform: translate3d(-50%,0,0);
        background-color: #fff;
    }
    .main-menu .navbar-nav .eg-active .menu-content .enhanced-nav  ~ .menu-content-bg {
        display: none !important;
    }
    }
    
    

    @media (min-width: 992px) and (max-width: 1100px){
        html body .navbar-expand-lg>.container{
            max-width: 100% !important;
        }
        html body nav .navbar-nav > .nav-item.dropdown.d-lg-block > .nav-link {
            padding: 0.5625rem 0.5rem !important;
        }
    }