Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var d7 = d7||{};
- d7.Ads = new function() {
- const me = this;
- me.checkAioBanner = function(){
- var hasBanner = false;
- var $slots = $('.aio-slot');
- if ($slots.length==0) return;
- //ads are loaded, check if shown
- $slots.each(function () {
- if($(this).height()>20) hasBanner = true;
- });
- var hb = hasBanner?1:0;
- //aio is loaded and shows empty slots, report to server
- $.ajax({
- url: '/script/aio/',
- data:{shown:hb},
- type: 'get'
- });
- };
- me.mobileSBinit = function(){
- var bannerId = 'adfox_154400455424238292';
- if (d7.SHOW_ADS && document.getElementById(bannerId)) {
- var banner = $('#'+bannerId);
- var bannerWrapper = $('.mobile-sticky-banner');
- var bannerCanvas = $('.mobile-sticky-banner-canvas');
- var adName = ["clickio_area_659932", "clickio_area_659933"];
- var checkSlot = function(slotId) {
- return adName.some(function(adName) {
- return slotId.indexOf(adName) !== -1;
- });
- }
- window.googletag = window.googletag || {};
- window.googletag.cmd = window.googletag.cmd || [];
- googletag.cmd.push(function(){
- googletag.pubads().addEventListener("slotRenderEnded", function(event){
- var slotId = event.slot.getSlotId().getId();
- if(checkSlot(slotId) && event.slot.getResponseInformation()) {
- bannerCanvas.css('background-color','#333');
- setTimeout(function () {
- $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
- e.preventDefault();
- bannerWrapper.remove();
- });
- }, 4000);
- }
- });
- googletag.pubads().addEventListener("slotResponseReceived", function(event){
- var slotId = event.slot.getSlotId().getId();
- if(checkSlot(slotId) && !event.slot.getResponseInformation()) {
- bannerWrapper.remove();
- }
- });
- });
- setTimeout(function () {
- $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
- e.preventDefault();
- bannerWrapper.remove();
- });
- }, 5000);
- setTimeout(function () {
- if (banner.is(':empty')) {
- bannerWrapper.remove();
- }
- }, 4000);
- bannerWrapper.show().addClass('active');
- bannerCanvas.css('background','transparent');
- adfoxAdd([{
- ownerId: 277363,
- containerId: bannerId,
- params: {pp: banner.data('pp'), ps: banner.data('ps'), p2: banner.data('p2')},
- // onRender: function() {
- //
- // bannerCanvas.css('background-color','#333');
- //
- // setTimeout(function () {
- // $('.mobile-sticky-banner .close-button').css('display', 'block').on('touchstart click', function (e) {
- // e.preventDefault();
- // bannerWrapper.remove();
- // });
- // }, 4000);
- // },
- // onError: function(){
- // bannerWrapper.remove();
- // },
- // onStub: function(){
- // bannerWrapper.remove();
- // }
- }]);
- }
- };
- me.youtubeBanner = function(){
- if (typeof YOUTUBE_VIDEO !== 'undefined' && YOUTUBE_VIDEO.length) {
- d7.withHandlebars(function(){
- var template = Handlebars.templates.block_youtube({
- videos: YOUTUBE_VIDEO,
- });
- $(template).insertAfter('#youtube_banner');
- $( document ).one( 'inview', '.block-type-youtube', function(event) {
- _gaq.push(['_trackEvent', 'youtube_channel', 'inview', '', 0, false]);
- });
- $( document ).on( 'click', '.block-type-youtube .button-subscribe', function(event) {
- _gaq.push(['_trackEvent', 'youtube_channel', 'subscribe_click', '', 0, false]);
- });
- var content_width = $(".block-type-youtube").width();
- $(".block-type-youtube iframe").each(function() {
- var ratio = content_width / $(this).width();
- $(this).height($(this).height() * ratio);
- $(this).width($(this).width() * ratio);
- });
- });
- }
- };
- me.d7init = function () {
- setTimeout(me.checkAioBanner, 8000);
- };
- return me;
- }();
- //should run before jquery.inview.js plugin is loaded
- d7.Ads.d7init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement