Advertisement
anatolionobre

BannerOver Exp 2swf

Oct 3rd, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--
  2.  
  3. Last update: 30/10/2014
  4.  
  5. 21/05/2014: Multiplas opções de expansão/fechar
  6. 22/11: Possibilidade de forçar Btn Fechar
  7. 22/11: Possibilidade de servir vídeo via Newsl
  8. 22/11: Possibilidade de servir SWF ou imagem
  9. 21/11: clickTag Overlay
  10.  
  11.  -->
  12.  
  13. <img src="%%VIEW_URL_UNESC%%http://s0.2mdn.net/dot.gif" width="1" height="1" style="display:none"/>
  14.  
  15.  
  16. <script type='text/javascript'>
  17.  
  18. if (typeof DFP_bo ==='undefined'){
  19.  
  20. var DFP_bo =   {
  21.  
  22.                 //SWF1/IMG1 (normal)
  23.                 swf1: '%%FILE:SWF1%%',
  24.                     width: '980',
  25.                     height: '100',
  26.                
  27.                 //SWF2/IMG2 (expandido)
  28.                     swf2: '%%FILE:SWF2%%',
  29.                     width2: '980',
  30.                     height2: '430',
  31.                
  32.                     ForceBtnFechar: true, //Quando não existe mesmo botão "label de fechar"
  33.                     ForceBtnFecharOverlay: false, //Coloca overlay sobre o swf2, com ação de fechar (Já existe o "label de fechar")
  34.                
  35.                    
  36.                     ForceBtnFecharWidth: 80, //Largura da área de overlay
  37.                     ForceBtnFecharHeight: 30, //Altura da área de overlay
  38.                     ForceBtnFecharBottom: 0, // Posição Y da área de Overlay. Normalmente está encostada ao bottom do ad
  39.                     ForceBtnFecharRight: 0, // Posição Y da área de Overlay. Normalmente está alinhado à direita
  40.                
  41.                
  42.                     videoNewsl: false, //puxa vídeo no newsl, com o nosso player
  43.                     videoNewslIframeUrl: 'http://newsl.iol.pt/pub/campanhas/missaosorriso/iframe-vid.html',
  44.                     videoNewslVideoUrl: 'video.flv',
  45.                     videoNewsWidth: 465, //Largura do video
  46.                     videoNewsHeight: 340, //Altura do video
  47.                     videoNewsTop: 50, // Posição Y da área de video sobre o ad.
  48.                     videoNewsLeft: 50, // Posição X da área de video sobre o ad.
  49.                
  50.                
  51.                  mode: 'transparent', //alterar por transparent, se desejado
  52.                  clickTagOverlay: true, //Coloca Evento de expansão com Overlay no swf1
  53.                  
  54.                
  55.                 //DO NOT CHANGE BELOW
  56.                 click: '%%CLICK_URL_ESC%%%%DEST_URL%%',
  57.                 dfpmacro: '%%CLICK_URL_ESC%%',
  58.                
  59.                 pre_utm_build: function () {if(this.click.indexOf('?') > -1){return '%26';}else{return '?'}},  
  60.                 utm_content_value: function(){return this.width+'x'+this.height}, //nome/variação do ad
  61.                 utm_source_value: document.domain, //default is document value
  62.                 utm_build: function(){return this.pre_utm_build()+'utm_source%3D'+this.utm_source_value+'%26utm_medium%3D'+this.utm_medium_value+'%26utm_content%3D'+this.utm_content_value()+'%26utm_campaign%3D'+this.utm_campaign_value+''},
  63.                 zclk: function(){if(this.utm){return this.dfpmacro+this.click+this.utm_build()}else{return this.click}},
  64.                 debug: function(m){try{console.log('ADSERVER DEBUG POS: '+m)}catch(e){}},
  65.                 swfOurl: 'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
  66.            
  67.                
  68.                 validate: function (param, default_value){
  69.                         if (param == ''){param = default_value}
  70.                         return param;
  71.                 },
  72.                
  73.                 getEl: function (i){return document.getElementById(i)},
  74.                
  75.                 pixel: function(p) {
  76.                         if(p){
  77.                                 img = new Image(1,1)
  78.                                 img.src = DFP_bo.srcMacro(p);
  79.                                 img.style.display='none';
  80.                                 return img;
  81.                         }
  82.                 },
  83.                 Image: function(file, selector, w, h, click){
  84.                         if(!click){click = DFP_bo.click}
  85.                         DFP_bo.getEl(selector).innerHTML='<a href='+click+' target="_blank"><img src='+file+' alt="" width='+w+' height='+h+' border="0" /></a>';
  86.                
  87.                 },
  88.                        
  89.                                        
  90.        
  91.                 bannerOver: function (pixels, click, anim) {
  92.                         anim = anim || false;
  93.                
  94.                        
  95.                         var pivot = '#bannerover';
  96.                         if(!$(pivot).length) {
  97.                                 var bo=$('<div></div>');
  98.                                 bo.attr('id', pivot);  
  99.                                 $('body').append(bo);
  100.                         }
  101.                  
  102.                         /* Do not change below */
  103.                         $(pivot).css('display','block');
  104.                         $(pivot).css('width','100%');
  105.                         $(pivot).css('margin','0 auto');
  106.                        
  107.                         if (anim) {
  108.                         $(pivot).animate({
  109.                                 height: pixels+'px'
  110.                        
  111.                         }, 2000, function() {
  112.                                 if (click != undefined){
  113.                                         $(this).css('cursor','pointer');
  114.                                         $(this).click(function() {
  115.                                                 window.open(click)
  116.                                         });
  117.                                 };
  118.                         });
  119.                         }else {
  120.                         $(pivot).css('height',pixels+'px');
  121.                                 if (click != undefined){
  122.                                         $(pivot).css('cursor','pointer');
  123.                                         $(pivot).click(function() {
  124.                                                 window.open(click)
  125.                                         });
  126.                                 };
  127.                         }
  128.                 },
  129.                
  130.                
  131.                 iframeScript3rd: function(container, src, w, h, beacon){
  132.                         var t;
  133.                         src.indexOf('bs.serving-sys.com')>-1 ? t = DFP_bo.ebIfrm : t= DFP_bo.Ifrm3rd;
  134.                         DFP_bo.iframeGen(DFP_bo.srcMacro(t+escape(src)), container, w, h);
  135.                 },
  136.                
  137.                
  138.                 iframeGen: function(src, container, w, h) {
  139.                         var zcont='<IFRAME SRC='+src+' WIDTH='+w+' HEIGHT='+h+' MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" FRAMEBORDER="0" SCROLLING="no"></iframe>';
  140.                         if (document.getElementById(container)){
  141.                                 document.getElementById(container).innerHTML = zcont;
  142.                         }else{try{console.log('Adserver_Error: trying to append content to an inexistent container: tag id: 223');}catch(e){};}
  143.                 },
  144.                
  145.        
  146.        
  147.                 Banner: function(file, selector, w1, h1, mode, click){
  148.                         var r=Math.floor(Math.random()*110)
  149.                         DFP_bo.domSwf('temp'+r, selector);
  150.                         DFP_bo.gen(file, 'temp'+r, w1, h1, mode, click);
  151.                 },
  152.        
  153.                
  154.  
  155.                
  156.                 domSwf: function(el, who, where, w, h ){
  157.                        
  158.                         var newEl = document.createElement('div');
  159.                         newEl.id = el;
  160.                         if (who == 'body'){
  161.                                 var y = document.getElementsByTagName('body')[0];
  162.                         }else{
  163.                                 var y = document.getElementById (who);
  164.                         }
  165.                         if(where == 'first'){
  166.                                 y.insertBefore(newEl, y.firstChild);
  167.                         }else{
  168.                                 y.appendChild(newEl);
  169.                         }
  170.                 },
  171.                
  172.                 getAd: function(file, selector, w1, h1, mode, click){
  173.                
  174.                         var t = setInterval(function() {
  175.                                 if (typeof swfobject != 'undefined') {
  176.                                         if (swfobject.hasFlashPlayerVersion('8.0.0')) {
  177.                                                 if(!click){click = escape(DFP_bo.zclk())}
  178.                                                 var flashvars = {
  179.                                                         ad: 'DFP_bo.AS2JS223',
  180.                                                         clickTag: click,
  181.                                                         clickTAG: click,
  182.                                                         clicktag: click
  183.                                                 }
  184.                                                 var params = {
  185.                                                         menu: 'false',
  186.                                                         quality: 'high',
  187.                                                         wmode: mode,
  188.                                                         AllowScriptAccess: 'always'
  189.                                                 }
  190.                                                 var attributes = {id: selector}
  191.                                                 swfobject.embedSWF(file, selector, w1, h1, '8.0.0', '', flashvars, params, attributes);
  192.                                         };
  193.                                         clearInterval(t);
  194.                                         t = null;
  195.                                 }
  196.                         }, 250);
  197.                 },
  198.                
  199.                                
  200.                 load: function (what) {
  201.                         var head = document.getElementsByTagName('head')[0];
  202.                         var script = document.createElement('script');
  203.                         script.type = 'text/javascript';
  204.                         script.src = what;
  205.                         head.appendChild(script);
  206.                 },
  207.                
  208.                 gen: function(file, selector, w1, h1, mode, click){
  209.                         if (typeof swfobject != 'undefined') {
  210.                                 DFP_bo.getAd(file, selector, w1, h1, mode, click);
  211.                         }else{
  212.                                 DFP_bo.load(DFP_bo.swfOurl);
  213.                                 DFP_bo.getAd(file, selector, w1, h1, mode, click);
  214.                         }
  215.                 },
  216.                
  217.                 srcMacro: function (src){
  218.                         var ord=Math.floor(Math.random()*10001)
  219.                         if(src.indexOf('rand')>-1){src= src.replace(/rand/gi, ord);}
  220.                         //if(src.indexOf('click')>-1){src= src.replace(/click/gi, DFP_bo.zclk());}
  221.                         return src;
  222.                 },    
  223.         mycounter: function(who, what){
  224.                 if (document.getElementById(who)){
  225.                                 switch(what){
  226.                                         case 'destroy':
  227.                                         //      var el = document.getElementById(who);
  228.                                         //      el.parentNode.removeChild(el);
  229.                                         $('#'+who).fadeOut('slow', function() {
  230.                                                 $('#'+who).remove();
  231.                                                 document.body.style.overflow = 'auto';
  232.                                                 $('#barraIOL').fadeIn();
  233.                                         });
  234.                                                
  235.                                         break;
  236.                                         case 'hide':
  237.                                                 var el = document.getElementById(who);
  238.                                                 el.style.display = 'none';
  239.                                                
  240.                                         break;
  241.                                         case 'empty':
  242.                                                 var el = document.getElementById(who);
  243.                                                 while (el.hasChildNodes()){
  244.                                                         el.removeChild(el.lastChild);
  245.                                                 };
  246.                                                
  247.                                         break;
  248.                                         case 'reload':
  249.                                                 if(reloadAd){
  250.                                                 var el = document.getElementById(who);
  251.                                                 el.parentNode.removeChild(el);
  252.                                                 reloadAd(223);
  253.                                                 }
  254.                                         break;
  255.                                         default:
  256.                                                 var el = document.getElementById(who);
  257.                                                 el.parentNode.removeChild(el);
  258.                                
  259.                                 };
  260.                         };
  261.                 },
  262.                
  263.                
  264.                 //event control from actionscript
  265.                 AS2JS223: function (what) {
  266.                
  267.                         if(what == 'close'){
  268.                                 try{console.log('close');}catch(e){};
  269.                                         DFP_bo.mycounter('zahirWrapper223', 'destroy')
  270.                                
  271.                        
  272.                         }else if(what == 'open'){
  273.                                 try{console.log('open');}catch(e){};
  274.                                 DFP_bo.Layer('body', '$width', '$height', DFP_bo.pixelTop(), DFP_bo.pixelLeft() , DFP_bo.destroyCounter());
  275.                                 DFP_bo.gen('$banner', 'zahirLayer2223', '$width', '$height', 'opaque');
  276.                         }
  277.                 }
  278. };
  279.  
  280.  
  281.  function yourFunctionToRun(){
  282.          $(function() {
  283.                 //DO IT
  284.  
  285.                 $('#LDB1').remove();
  286.                 $('#bannerover').css('display','block');
  287.                 $('#bannerover').css('height',DFP_bo.height+'px');
  288.                 $('#bannerover').css('textAlign','center');
  289.                 $('#bannerover').css('width',DFP_bo.width+'px');
  290.                 $('#bannerover').css('position','relative');
  291.                 $('#bannerover').css('margin','10px auto');
  292.            
  293.            
  294.         DFP_bo.Banner(DFP_bo.swf1, 'bannerover', DFP_bo.width, DFP_bo.height, DFP_bo.mode)
  295.         //Gera layer por cima do swf1- no caso de não ter esta ação de rollover no Actionscript
  296.        
  297.         if (DFP_bo.clickTagOverlay) {
  298.             $('#bannerover').prepend('<div id="BO-clicktag" style="cursor:pointer; position:absolute; top: 0px; right: 0px; z-index 10000; width: 980px; cursor:pointer; height:100px"><img src="http://s0.2mdn.net/dot.gif" height="100" width="980"/></div>');
  299.             $('#BO-clicktag').mouseover(function() {openThis()});
  300.        };
  301.        
  302.        
  303.    
  304.        
  305.         });
  306. }
  307.  
  308. function runYourFunctionWhenJQueryIsLoaded() {
  309.     if (window.$){
  310.         //possibly some other JQuery checks to make sure that everything is loaded here
  311.  
  312.         yourFunctionToRun();
  313.     } else {
  314.         setTimeout(runYourFunctionWhenJQueryIsLoaded, 50);
  315.     }
  316. }
  317.  
  318. runYourFunctionWhenJQueryIsLoaded();
  319.                
  320.  
  321.        
  322.        
  323.        
  324.        
  325. function openThis() {
  326.         DFP_bo.debug('openThis f called');
  327.             $('#bannerover').empty();
  328.                //DFP_bo.Image(DFP_bo.swf2, 'bannerover', DFP_bo.width2, DFP_bo.height2) //if image
  329.                DFP_bo.Banner(DFP_bo.swf2, 'bannerover', DFP_bo.width2, DFP_bo.height2, DFP_bo.mode);
  330.                      
  331.                                         $('#bannerover').animate({
  332.                                         height: DFP_bo.height2+'px'
  333.                                         }, 2000, function() {
  334.                                        
  335.                         if (DFP_bo.videoNewsl) {               
  336.                             $('#bannerover').append('<div id="videoBO" style="position:absolute; top: '+DFP_bo.videoNewsTop+'px; left:'+DFP_bo.videoNewsLeft+'px;  z-index: 10000; width: '+DFP_bo.videoNewsWidth+'px; height: '+DFP_bo.videoNewsHeight+'px;"></div>');    
  337.                             DFP_bo.iframeGen(''+DFP_bo.videoNewslIframeUrl+'?file='+DFP_bo.videoNewslVideoUrl+'&w='+DFP_bo.videoNewsWidth+'&h='+DFP_bo.videoNewsHeight+'', 'videoBO', DFP_bo.videoNewsWidth, DFP_bo.videoNewsHeight);  
  338.                        
  339.                         };
  340.                        
  341.                         if (DFP_bo.ForceBtnFechar) {
  342.                        
  343.                             $('#bannerover').append('<div style="position:absolute; bottom:'+DFP_bo.ForceBtnFecharBottom+'px; right:'+DFP_bo.ForceBtnFecharRight+'px; cursor:pointer; font-size: 11px; margin: 2px auto 0px; padding:4px; background-color:#333; display:block; text-align:right; color: #fff;" id="closepointer">FECHAR</div>');
  344.                             $('#closepointer').click(function() {closeThis() });
  345.                        
  346.                         };
  347.                        
  348.                        
  349.                         if (DFP_bo.ForceBtnFecharOverlay) {
  350.                        
  351.                             $('#bannerover').append('<div style="position:absolute; bottom:'+DFP_bo.ForceBtnFecharBottom+'px; right:'+DFP_bo.ForceBtnFecharRight+'px; width: '+DFP_bo.ForceBtnFecharWidth+'px; height: '+DFP_bo.ForceBtnFecharHeight+'px; cursor:pointer; font-size: 11px; margin: 2px auto 0px; padding:4px; background-color:#333; display:block; text-align:right; color: #fff;" id="closepointer">FECHAR</div>');
  352.                             $('#closepointer').click(function() {closeThis() });
  353.                        
  354.                         };
  355.                        
  356.                        
  357.  
  358.  
  359.                                        
  360.                                 });
  361.                                
  362.                                  
  363.  
  364.  
  365.        
  366.         };
  367.        
  368.        
  369.  
  370.          
  371.        
  372.         function closeThis() {
  373.  
  374.         DFP_bo.debug('[DFP_bo] ->closeThis () ');
  375.         $('#bannerover').animate({
  376.                height: parseInt(DFP_bo.height)+20+'px'
  377.                                
  378.            }, 2000, function() {
  379.                  $('#bannerover').empty()
  380.                  DFP_bo.Banner(DFP_bo.swf1, 'bannerover', DFP_bo.width, DFP_bo.height, DFP_bo.mode);
  381.                  
  382.                  if (DFP_bo.clickTagOverlay) {
  383.                     $('#bannerover').prepend('<div id="BO-clicktag" style="cursor:pointer; position:absolute; top: 0px; right: 0px; z-index 10000; width: 980px; cursor:pointer; height:100px"><img src="http://s0.2mdn.net/dot.gif" height="100" width="980"/></div>');
  384.                     $('#BO-clicktag').click(function() {window.open(DFP_bo.click) });
  385.                 };      
  386.  
  387.                //EXPANDIR
  388.                $('#bannerover').append('<div style="position:absolute; top: 100px; right:0px; cursor:pointer; font-size: 11px; margin: 2px auto 0px; padding:4px; background-color:#333; display:block; text-align:right; color: #fff;" id="openpointer">EXPANDIR</div>');
  389.                 $('#openpointer').click(function() {openThis() });
  390.                                                
  391.                                                
  392.                });
  393.                                
  394.     };
  395.                                                                
  396.                                                        
  397. function pub_close() { closeThis() };
  398.                                
  399.                            
  400.                                
  401.                
  402. };
  403.  
  404.  
  405.  </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement