Advertisement
clickio

7dach.ru sticky callback

May 15th, 2020
2,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var d7 = d7||{};
  2. d7.Ads = new function() {
  3.     const me = this;
  4.     me.checkAioBanner = function(){
  5.         var hasBanner = false;
  6.         var $slots = $('.aio-slot');
  7.         if ($slots.length==0) return;
  8.         //ads are loaded, check if shown
  9.         $slots.each(function () {
  10.             if($(this).height()>20) hasBanner = true;
  11.         });
  12.         var hb = hasBanner?1:0;
  13.         //aio is loaded and shows empty slots, report to server
  14.         $.ajax({
  15.             url: '/script/aio/',
  16.             data:{shown:hb},
  17.             type: 'get'
  18.         });
  19.     };
  20.     me.mobileSBinit = function(){
  21.  
  22.         var bannerId = 'adfox_154400455424238292';
  23.  
  24.         if (d7.SHOW_ADS && document.getElementById(bannerId)) {
  25.  
  26.             var banner = $('#'+bannerId);
  27.             var bannerWrapper = $('.mobile-sticky-banner');
  28.             var bannerCanvas = $('.mobile-sticky-banner-canvas');
  29.  
  30.  
  31.             var adName = ["clickio_area_659932", "clickio_area_659933"];
  32.  
  33.             var checkSlot = function(slotId) {
  34.                 return adName.some(function(adName) {
  35.                     return slotId.indexOf(adName) !== -1;
  36.                 });
  37.             }
  38.             window.googletag = window.googletag || {};
  39.             window.googletag.cmd = window.googletag.cmd || [];
  40.             googletag.cmd.push(function(){
  41.  
  42.                 googletag.pubads().addEventListener("slotRenderEnded", function(event){
  43.                     var slotId = event.slot.getSlotId().getId();
  44.                     if(checkSlot(slotId) && event.slot.getResponseInformation()) {
  45.                         bannerCanvas.css('background-color','#333');
  46.                         setTimeout(function () {
  47.                             $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
  48.                                 e.preventDefault();
  49.                                 bannerWrapper.remove();
  50.                             });
  51.                         }, 4000);
  52.                     }
  53.                 });
  54.  
  55.                 googletag.pubads().addEventListener("slotResponseReceived", function(event){
  56.                     var slotId = event.slot.getSlotId().getId();
  57.                     if(checkSlot(slotId) && !event.slot.getResponseInformation()) {
  58.                         bannerWrapper.remove();
  59.                     }
  60.                 });
  61.             });
  62.  
  63.             setTimeout(function () {
  64.                 $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
  65.                     e.preventDefault();
  66.                     bannerWrapper.remove();
  67.                 });
  68.             }, 5000);
  69.  
  70.             setTimeout(function () {
  71.                 if (banner.is(':empty')) {
  72.                     bannerWrapper.remove();
  73.                 }
  74.             }, 4000);
  75.  
  76.             bannerWrapper.show().addClass('active');
  77.             bannerCanvas.css('background','transparent');
  78.  
  79.             adfoxAdd([{
  80.                 ownerId: 277363,
  81.                 containerId: bannerId,
  82.                 params: {pp: banner.data('pp'), ps: banner.data('ps'), p2: banner.data('p2')},
  83. //              onRender: function() {
  84. //
  85. //                  bannerCanvas.css('background-color','#333');
  86. //
  87. //                  setTimeout(function () {
  88. //                      $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
  89. //                          e.preventDefault();
  90. //                          bannerWrapper.remove();
  91. //                      });
  92. //                  }, 4000);
  93. //              },
  94. //              onError: function(){
  95. //                  bannerWrapper.remove();
  96. //              },
  97. //              onStub: function(){
  98. //                  bannerWrapper.remove();
  99. //              }
  100.             }]);
  101.         }
  102.     };
  103.     me.youtubeBanner = function(){
  104.         if (typeof YOUTUBE_VIDEO !== 'undefined' && YOUTUBE_VIDEO.length) {
  105.             d7.withHandlebars(function(){
  106.                 var template = Handlebars.templates.block_youtube({
  107.                     videos: YOUTUBE_VIDEO,
  108.                 });
  109.                 $(template).insertAfter('#youtube_banner');
  110.  
  111.                 $( document ).one( 'inview', '.block-type-youtube', function(event) {
  112.                     _gaq.push(['_trackEvent', 'youtube_channel', 'inview', '', 0, false]);
  113.                 });
  114.  
  115.                 $( document ).on( 'click', '.block-type-youtube .button-subscribe', function(event) {
  116.                     _gaq.push(['_trackEvent', 'youtube_channel', 'subscribe_click', '', 0, false]);
  117.                 });
  118.                 var content_width = $(".block-type-youtube").width();
  119.                 $(".block-type-youtube iframe").each(function() {
  120.                     var ratio = content_width / $(this).width();
  121.                     $(this).height($(this).height() * ratio);
  122.                     $(this).width($(this).width() * ratio);
  123.                 });
  124.             });
  125.  
  126.  
  127.         }
  128.     };
  129.     me.d7init = function () {
  130.         setTimeout(me.checkAioBanner, 8000);
  131.  
  132.     };
  133.     return me;
  134. }();
  135. //should run before jquery.inview.js plugin is loaded
  136. d7.Ads.d7init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement