Skip to content

Commit 4273734

Browse files
author
m.sorochuk
committed
Merge branch 'master' of https://github.com/prebid/Prebid.js
* 'master' of https://github.com/prebid/Prebid.js: (43 commits) Merge Prebid 1.0 to Master (prebid#1936) Prebid.js 0.34.1 release Vertamedia adapter outstream support (prebid#1860) Expose native image-type asset dimensions on bid response object (prebid#1919) Remove for of (prebid#1932) Unit-test fix (prebid#1927) Remove description_url (prebid#1922) Trion Interactive Adapter Bugfix (prebid#1925) Remove config setting from Optimatic adapter (prebid#1909) IE bug fix (prebid#1930) Clarify ad unit media filtering warning (prebid#1903) Add ReadPeak Bid Adapter (prebid#1838) Change clone function to make deep copies (prebid#1910) Serverbid 1.0 (prebid#1802) sekindoUM for prebid1.0 (prebid#1777) update auctionId to be requestId (prebid#1896) bug fixed to populate userSync default values (prebid#1897) Increment pre version AdkernelAdn analytics adapter (prebid#1868) Justpremium Adapter: use `filter` instead of `...new Set` (prebid#1895) ...
2 parents f878902 + 377c4c2 commit 4273734

File tree

246 files changed

+10148
-34534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+10148
-34534
lines changed

.babelrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"presets": ["es2015"],
3-
"plugins": ["transform-object-assign", "transform-es3-property-literals", "transform-es3-member-expression-literals"]
3+
"plugins": [
4+
"transform-object-assign",
5+
"transform-es3-property-literals",
6+
"transform-es3-member-expression-literals"
7+
]
48
}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ To run the unit tests:
113113
```bash
114114
gulp test
115115
```
116+
To run tests for a single file:
117+
118+
```bash
119+
gulp test --file "path/to/spec/file.js"
120+
```
116121

117122
To generate and view the code coverage reports:
118123

gulpfile.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var gulpif = require('gulp-if');
2828
var sourcemaps = require('gulp-sourcemaps');
2929
var through = require('through2');
3030
var fs = require('fs');
31+
var jsEscape = require('gulp-js-escape');
3132

3233
var prebid = require('./package.json');
3334
var dateString = 'Updated : ' + (new Date()).toISOString().substring(0, 10);
@@ -296,10 +297,21 @@ gulp.task('e2etest-report', function() {
296297
}, 5000);
297298
});
298299

299-
gulp.task('build-postbid', function() {
300+
// This task creates postbid.js. Postbid setup is different from prebid.js
301+
// More info can be found here http://prebid.org/overview/what-is-post-bid.html
302+
gulp.task('build-postbid', ['escape-postbid-config'], function() {
303+
var fileContent = fs.readFileSync('./build/postbid/postbid-config.js', 'utf8');
304+
300305
return gulp.src('./integrationExamples/postbid/oas/postbid.js')
301-
.pipe(uglify())
302-
.pipe(gulp.dest('build/dist'));
306+
.pipe(replace('\[%%postbid%%\]', fileContent))
307+
.pipe(gulp.dest('build/postbid/'));
308+
});
309+
310+
// Dependant task for building postbid. It escapes postbid-config file.
311+
gulp.task('escape-postbid-config', function() {
312+
gulp.src('./integrationExamples/postbid/oas/postbid-config.js')
313+
.pipe(jsEscape())
314+
.pipe(gulp.dest('build/postbid/'));
303315
});
304316

305317
module.exports = nodeBundle;

integrationExamples/gpt/hello_world.html

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -12,91 +12,91 @@
1212
-->
1313

1414
<html>
15-
<head>
16-
<script>
17-
var PREBID_TIMEOUT = 700;
18-
19-
var adUnits = [{
20-
code: 'div-gpt-ad-1460505748561-0',
21-
sizes: [[300, 250], [300,600]],
22-
23-
// Replace this object to test a new Adapter!
24-
bids: [{
25-
bidder: 'appnexus',
26-
params: {
27-
placementId: '10433394'
28-
}
29-
}]
30-
31-
}];
32-
33-
var pbjs = pbjs || {};
34-
pbjs.que = pbjs.que || [];
35-
36-
</script>
37-
38-
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
39-
<script>
40-
var googletag = googletag || {};
41-
googletag.cmd = googletag.cmd || [];
42-
googletag.cmd.push(function() {
43-
googletag.pubads().disableInitialLoad();
44-
});
45-
46-
pbjs.que.push(function() {
47-
pbjs.addAdUnits(adUnits);
48-
pbjs.requestBids({
49-
bidsBackHandler: sendAdserverRequest
50-
});
51-
});
52-
53-
function sendAdserverRequest() {
54-
if (pbjs.adserverRequestSent) return;
55-
pbjs.adserverRequestSent = true;
15+
<head>
16+
<script>
17+
var PREBID_TIMEOUT = 700;
18+
19+
var adUnits = [{
20+
code: 'div-gpt-ad-1460505748561-0',
21+
sizes: [[300, 250], [300,600]],
22+
23+
// Replace this object to test a new Adapter!
24+
bids: [{
25+
bidder: 'appnexusAst',
26+
params: {
27+
placementId: '10433394'
28+
}
29+
}]
30+
31+
}];
32+
33+
var pbjs = pbjs || {};
34+
pbjs.que = pbjs.que || [];
35+
36+
</script>
37+
38+
<script type="text/javascript" src="../../build/dev/prebid.js" async></script>
39+
<script>
40+
var googletag = googletag || {};
41+
googletag.cmd = googletag.cmd || [];
5642
googletag.cmd.push(function() {
57-
pbjs.que.push(function() {
58-
pbjs.setTargetingForGPTAsync();
59-
googletag.pubads().refresh();
43+
googletag.pubads().disableInitialLoad();
44+
});
45+
46+
pbjs.que.push(function() {
47+
pbjs.addAdUnits(adUnits);
48+
pbjs.requestBids({
49+
bidsBackHandler: sendAdserverRequest
6050
});
6151
});
62-
}
63-
64-
setTimeout(function() {
65-
sendAdserverRequest();
66-
}, PREBID_TIMEOUT);
67-
68-
</script>
69-
70-
<script>
71-
(function () {
72-
var gads = document.createElement('script');
73-
gads.async = true;
74-
gads.type = 'text/javascript';
75-
var useSSL = 'https:' == document.location.protocol;
76-
gads.src = (useSSL ? 'https:' : 'http:') +
77-
'//www.googletagservices.com/tag/js/gpt.js';
78-
var node = document.getElementsByTagName('script')[0];
79-
node.parentNode.insertBefore(gads, node);
80-
})();
81-
</script>
82-
83-
<script>
84-
googletag.cmd.push(function () {
85-
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
86-
87-
googletag.pubads().enableSingleRequest();
88-
googletag.enableServices();
89-
});
90-
</script>
91-
</head>
92-
93-
<body>
94-
<h2>Prebid.js Test</h2>
95-
<h5>Div-1</h5>
96-
<div id='div-gpt-ad-1460505748561-0'>
97-
<script type='text/javascript'>
98-
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
99-
</script>
100-
</div>
101-
</body>
102-
</html>
52+
53+
function sendAdserverRequest() {
54+
if (pbjs.adserverRequestSent) return;
55+
pbjs.adserverRequestSent = true;
56+
googletag.cmd.push(function() {
57+
pbjs.que.push(function() {
58+
pbjs.setTargetingForGPTAsync();
59+
googletag.pubads().refresh();
60+
});
61+
});
62+
}
63+
64+
setTimeout(function() {
65+
sendAdserverRequest();
66+
}, PREBID_TIMEOUT);
67+
68+
</script>
69+
70+
<script>
71+
(function () {
72+
var gads = document.createElement('script');
73+
gads.async = true;
74+
gads.type = 'text/javascript';
75+
var useSSL = 'https:' == document.location.protocol;
76+
gads.src = (useSSL ? 'https:' : 'http:') +
77+
'//www.googletagservices.com/tag/js/gpt.js';
78+
var node = document.getElementsByTagName('script')[0];
79+
node.parentNode.insertBefore(gads, node);
80+
})();
81+
</script>
82+
83+
<script>
84+
googletag.cmd.push(function () {
85+
googletag.defineSlot('/19968336/header-bid-tag-0', [[300, 250], [300, 600]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());
86+
87+
googletag.pubads().enableSingleRequest();
88+
googletag.enableServices();
89+
});
90+
</script>
91+
</head>
92+
93+
<body>
94+
<h2>Prebid.js Test</h2>
95+
<h5>Div-1</h5>
96+
<div id='div-gpt-ad-1460505748561-0'>
97+
<script type='text/javascript'>
98+
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1460505748561-0'); });
99+
</script>
100+
</div>
101+
</body>
102+
</html>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<script type="text/javascript">
2+
var pbjs = pbjs || {};
3+
pbjs.que = pbjs.que || [];
4+
5+
(function() {
6+
var pbjsEl = document.createElement("script"); pbjsEl.type = "text/javascript";
7+
pbjsEl.async = true; var isHttps = 'https:' === document.location.protocol;
8+
pbjsEl.src = (isHttps ? "https" : "http") + "://acdn.adnxs.com/prebid/not-for-prod/prebid.js";
9+
var pbjsTargetEl = document.getElementsByTagName("head")[0];
10+
pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);
11+
})();
12+
13+
pbjs.que.push(function() {
14+
var adUnits = [{
15+
code: '[%%adUnitCode%%]',
16+
sizes: [%%sizes%%],
17+
bids: [%%adUnitBids%%]
18+
}];
19+
pbjs.addAdUnits(adUnits);
20+
21+
pbjs.requestBids({
22+
timeout: [%%timeout%%],
23+
bidsBackHandler: function() {
24+
var iframe = document.getElementById('postbid_if_3');
25+
var iframeDoc = iframe.contentWindow.document;
26+
var params = pbjs.getAdserverTargetingForAdUnitCode('[%%adUnitCode%%]');
27+
28+
// If any bidders return any creatives
29+
var bid;
30+
if(params && params['hb_adid']){
31+
var bid;
32+
for(i=0; i< pbjs._bidsReceived.length; i++ ) {
33+
if (params['hb_adid'] === pbjs._bidsReceived[i].adId) {
34+
bid = pbjs._bidsReceived[i];
35+
break;
36+
}
37+
}
38+
pbjs.renderAd(iframeDoc, params['hb_adid']);
39+
} else {
40+
// If no bidder return any creatives,
41+
// Passback 3rd party tag in Javascript
42+
iframe.width = [%%size0%%];
43+
iframe.height = [%%size1%%];
44+
iframeDoc.write('[%%passbackTagHtml%%]');
45+
}
46+
47+
var iframeResize = window.parent.document.getElementById('[%%targetId%%]');
48+
iframeResize.height = (bid.height) ? bid.height+'px' : '[%%size1%%]px';
49+
iframeResize.width = (bid.width) ? bid.width+'px' : '[%%size0%%]px';
50+
}
51+
});
52+
});
53+
</script>
54+
<iframe id='postbid_if_3' FRAMEBORDER="0" SCROLLING="no" MARGINHEIGHT="0" MARGINWIDTH="0" TOPMARGIN="0" LEFTMARGIN="0" ALLOWTRANSPARENCY="true" WIDTH="0" HEIGHT="0"></iframe>

integrationExamples/postbid/oas/postbid.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable */
12
(function(window){
23
var postbid = {};
34
postbid.que = [];
@@ -100,7 +101,22 @@
100101
}
101102

102103
postbid.que.push(function(conf) {
103-
var content = "\n <script type=\"text/javascript\">\n if (!Array.prototype.find) {\n Object.defineProperty(Array.prototype, 'find', {\n value: function(predicate) {\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n var o = Object(this);\n var len = o.length >>> 0;\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function');\n }\n var thisArg = arguments[1];\n var k = 0;\n while (k < len) {\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return kValue;\n }\n k++;\n }\n return undefined;\n }\n });\n }\n\n var pbjs = pbjs || {};\n pbjs.que = pbjs.que || [];\n\n (function() {\n var pbjsEl = document.createElement(\"script\"); pbjsEl.type = \"text/javascript\";\n pbjsEl.async = true; var isHttps = 'https:' === document.location.protocol;\n pbjsEl.src = (isHttps ? \"https\" : \"http\") + \"://acdn.adnxs.com/prebid/not-for-prod/prebid.js\";\n var pbjsTargetEl = document.getElementsByTagName(\"head\")[0];\n pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);\n })();\n\n pbjs.que.push(function() {\n var adUnits = [{\n code: '" + conf.adUnitCode + "',\n sizes: " + conf.adUnitSizes + ",\n bids: " + conf.adUnitBids + "\n }];\n\n pbjs.addAdUnits(adUnits);\n\n pbjs.requestBids({\n timeout: " + conf.timout + ",\n bidsBackHandler: function() {\n var iframe = document.getElementById('postbid_if_3');\n\n var iframeDoc = iframe.contentWindow.document;\n\n var params = pbjs.getAdserverTargetingForAdUnitCode('" + conf.adUnitCode + "');\n\n // If any bidders return any creatives\n var bid;\n if(params && params['hb_adid']){\n bid = pbjs._bidsReceived.find(function(bid) {\n return bid.adId === params['hb_adid'];\n });\n pbjs.renderAd(iframeDoc, params['hb_adid']);\n } else {\n // If no bidder return any creatives,\n // Passback 3rd party tag in Javascript\n\n iframe.width = '" + conf.adUnitSizes[0] + "';\n iframe.height = '" + conf.adUnitSizes[1] + "';\n\n iframeDoc.write('" + conf.passbackTagHtml + "');\n }\n\n var iframeResize = window.parent.document.getElementById('" + conf.targetId + "');\n iframeResize.height = (bid.height) ? bid.height+'px' : '" + conf.adUnitSizes[1] + "px';\n iframeResize.width = (bid.width) ? bid.width+'px' : '" + conf.adUnitSizes[0] + "px';\n }\n });\n });\n <"+ '' +"/script>\n <iframe id='postbid_if_3' FRAMEBORDER=\"0\" SCROLLING=\"no\" MARGINHEIGHT=\"0\" MARGINWIDTH=\"0\" TOPMARGIN=\"0\" LEFTMARGIN=\"0\" ALLOWTRANSPARENCY=\"true\" WIDTH=\"0\" HEIGHT=\"0\"></iframe>";
104+
var sizes = JSON.parse(conf.adUnitSizes);
105+
var timeout = conf.timeout;
106+
var adUnitCode = conf.adUnitCode;
107+
var adUnitBids = conf.adUnitBids;
108+
var targetId = conf.targetId;
109+
var passbackTagHtml = conf.passbackTagHtml;
110+
111+
var content = [%%postbid%%];
112+
content = content.replace(/\[%%targetId%%\]/g, targetId);
113+
content = content.replace(/\[%%adUnitCode%%\]/g, adUnitCode);
114+
content = content.replace(/\[%%timeout%%\]/g, timeout);
115+
content = content.replace(/\[%%adUnitBids%%\]/g, adUnitBids);
116+
content = content.replace(/\[%%passbackTagHtml%%\]/g, passbackTagHtml);
117+
content = content.replace(/\[%%sizes%%\]/g, conf.adUnitSizes);
118+
content = content.replace(/\[%%size0%%\]/g, sizes[0]);
119+
content = content.replace(/\[%%size1%%\]/g, sizes[1]);
104120

105121
var iframe = createIframe(conf.targetId);
106122
var div = document.getElementById(conf.divId);
@@ -116,3 +132,4 @@
116132
window.processQue = processQue;
117133

118134
})(window);
135+
/* eslint-enable */

0 commit comments

Comments
 (0)