Guest User

Untitled

a guest
Dec 10th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. window.track = function (action, adId) {
  2. var message = {message: 'Prebid Native', adId: adId};
  3. if (action === 'click') { message.action = 'click'; }
  4. window.parent.postMessage(JSON.stringify(message), '*');
  5. }
  6.  
  7. var render = function(bid, adUnitDivId) {
  8. // Can include CSS styles here, or just use styles from your site.
  9. var markup = `
  10. <style>
  11. .native-ad {
  12. background-color: #fff;
  13. border: 1px solid #EDEDED;
  14. border-radius: 4px;
  15. overflow: hidden;
  16. font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  17. font-size: 12px;
  18. height: 248px;
  19. width: 298px;
  20. position: relative;
  21. }
  22.  
  23. .inset-box {
  24. border-radius: 2px;
  25. background-color: #fff;
  26. position: absolute;
  27. padding: 2px 5px;
  28. }
  29.  
  30. .inset-box-text {
  31. display: block;
  32. height: 15px;
  33. font-size: 12px;
  34. line-height: 14px;
  35. text-align: center;
  36. color: #333333;
  37. text-decoration: none;
  38. }
  39.  
  40. .attribution {
  41. left: 10px;
  42. top: 10px;
  43. }
  44.  
  45. .image img {
  46. height: 158px;
  47. width: 298px;
  48. border-radius: 4px 4px 0 0;
  49. object-fit: cover;
  50. }
  51.  
  52. .advertiser {
  53. width: 96px;
  54. right: 10px;
  55. top: 10px;
  56. }
  57.  
  58. .title {
  59. height: 24px;
  60. text-align: center;
  61. margin-top: 10px;
  62. margin-bottom: 10px;
  63. }
  64.  
  65. .title a {
  66. color: #000000;
  67. font-size: 20px;
  68. font-weight: bold;
  69. line-height: 25px;
  70. text-decoration: none;
  71. }
  72.  
  73. .call-to-action {
  74. display: block;
  75. width: 77px;
  76. border-radius: 4px;
  77. background-color: #3E86C7;
  78. margin: 0 auto;
  79. padding: 8px 15.5px;
  80. text-align: center;
  81. text-decoration: none;
  82. }
  83.  
  84. .call-to-action-text {
  85. height: 18px;
  86. color: #FFFFFF;
  87. font-size: 14px;
  88. font-weight: bold;
  89. line-height: 17px;
  90. }
  91. </style>
  92. <div class='native-ad'>
  93. <div class='attribution inset-box'>
  94. <span class='inset-box-text'>Ad</span>
  95. </div>
  96. <div class='image'>
  97. <a href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');"><img src='${bid.native.image.url}'></a>
  98. </div>
  99. <div class='advertiser inset-box'>
  100. <a id='native-brand' class='inset-box-text' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">${bid.native.sponsoredBy}</a>
  101. </div>
  102. <div class='title'>
  103. <a id='native-title' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">${bid.native.title}</a>
  104. </div>
  105. <a class='call-to-action' href='${bid.native.clickUrl}' target='_blank' onclick="window.track('click', '${bid.adId}');">
  106. <span class='call-to-action-text'>Learn More</span>
  107. </a>
  108. </div>`
  109.  
  110. // Insert ad into document.
  111. var container = document.createElement("div");
  112. container.innerHTML = markup;
  113. document.getElementById(adUnitDivId).appendChild(container);
  114.  
  115. window.track('impression', bid.adId);
  116. };
  117.  
  118. window.NativeRenderer = render
Add Comment
Please, Sign In to add comment