jQuery - banderole ad & trigger

0 votes
346 views
added Nov 13, 2018 in jQuery by LC Marshal Captain (25,790 points)
<!-- banderole ads -->    
<div class="banderole">   
  <div class="banderole-content">   
    <span class="slide-close"><i class="ion-close"></i></span>    
    <div class="slide-trigger">   
      <div id='div-gpt-ad-xxxxxx77104045-0'></div>   
      <script>    
        googletag.cmd.push(function() {     
          googletag.display('div-gpt-ad-xxxxxx77104045-0');    
        });   
      </script>         
    </div>    
    <div class="slide-trigger trigger"></div>     
     <!-- /xxxxx1612/ListDev_Banderole -->
    <div id='div-gpt-ad-xxxxx75954162-0'></div>   
    <script>    
      googletag.cmd.push(function() {     
        googletag.display('div-gpt-ad-xxxxx75954162-0');    
      });       
    </script>   
  </div>    
</div>

<script>
 $(window).load(function() {
    var banderoleAd = $(".banderole-content > div[id^='div-gpt-ad']");
    if(banderoleAd.length > 0){
      $('.banderole .slide-trigger').addClass('on');

      $('.banderole .slide-trigger.trigger').on('click', function(){
        $(this).parent().parent().toggleClass('in');
      });
      $('.banderole .slide-close').on('click', function(){
        $(this).parent().parent().removeClass('in');
      });

      setTimeout(function(){
        $('.banderole').addClass('in');
      },300);
    }
 });

 $(window).scroll(function() {
    var banderole = $('.banderole');
    if(banderole.hasClass('in')){
      banderole.removeClass('in');
    }
 });
</script>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...