Skip to content

Commit

Permalink
fix click issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tushargugnani committed Jan 14, 2023
1 parent 2692f57 commit fa6deeb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions resources/dist/js/smart-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ fetch('/smart-banner-auto-placements')
});

//Remove the parent temp element (smart-ad-temp), since it messes with the CSS Design for some ads
var smartAd = document.querySelector('.smart-banner-temp');
if(smartAd){
let adSlug = smartAd.getAttribute('banner-slug');
smartAd.firstElementChild.setAttribute("banner-slug", adSlug);
smartAd.firstElementChild.classList.add("smart-banner");
document.querySelectorAll(".smart-banner-temp").forEach(EL => EL.replaceWith(...EL.childNodes));

//Attach click event
document.querySelector('.smart-banner').addEventListener('click', updateClick);
}
var smartAds = document.querySelectorAll('.smart-banner-temp');
//console.log(smartAds);
smartAds.forEach(function(smartAd){
let adSlug = smartAd.getAttribute('banner-slug');
smartAd.firstElementChild.setAttribute("banner-slug", adSlug);
smartAd.firstElementChild.classList.add("smart-banner");
smartAd.replaceWith(...smartAd.childNodes);
});

var smartAds = document.querySelectorAll('.smart-banner');
smartAds.forEach(function(smartAd){
smartAd.addEventListener('click', updateClick);
});

});

//Event listener function for updating clicks
Expand Down

0 comments on commit fa6deeb

Please sign in to comment.