-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample-creative-script.js
More file actions
executable file
·70 lines (55 loc) · 2.22 KB
/
example-creative-script.js
File metadata and controls
executable file
·70 lines (55 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var _pr_responsive_break_points = {
'width': [500],
'height': []
};
var _pr_responsive_ad_sizes = {
'width': ['pr-small', 'pr-medium', 'pr-large'],
'height': []
};
var _pr_ad_slot_index = 3;
var _pr_ad_connection;
var _pr_wrap;
function prInitAd(){
_pr_ad_connection = new prAdConnection(false, myCallback);
_pr_wrap = document.getElementById('pr-wrap');
_pr_wrap.addEventListener('click', function(event){
_pr_ad_connection.closeAd();
}, false);
_pr_ad_connection.updateAdSize = function(size, type){
switch(type){
case 'width':
_pr_ad_connection._ad_container.className = _pr_responsive_ad_sizes.width[size] + ' ' + _pr_responsive_ad_sizes.height[_pr_ad_connection._ad_size.height];
switch(size){
case 0:
_pr_ad_connection.sendMessageToPub({'hide': null});
break;
case 1:
_pr_ad_connection.sendMessageToPub({'reveal': null, 'setAdSize': {'width': '100%', 'height': '90px'}});
break;
case 2:
_pr_ad_connection.sendMessageToPub({'reveal': null, 'setAdSize': {'width': '100%', 'height': '300px'}});
break;
}
break;
case 'height':
_pr_ad_connection._ad_container.className = _pr_responsive_ad_sizes.width[_pr_ad_connection._ad_size.width] + ' ' + _pr_responsive_ad_sizes.height[size];
break;
}
}
_pr_ad_connection.fireNonImpression = function(){
//
}
_pr_ad_connection.createConnection(_pr_wrap, _pr_responsive_break_points, prPlacementId, _pr_ad_slot_index);
}
function pageScrollHandler(event){
_pr_ad_connection.log('page scroll = ' + event.scrollY + 'px');
}
function myCallback(message){
if(message == 'success'){
_pr_ad_connection.addPageListener('window', 'scroll', pageScrollHandler);
_pr_ad_connection.sendMessageToPub({'wrapElements': {'id': 'helloworld', 'elements': '#testid1, #testid3', 'class': 'itsraining'}});
_pr_ad_connection.sendMessageToPub({'wrapElements': {'id': 'goodbyeworld', 'elements': '.testclass', 'min': 3, 'max': 8, 'tag': 'a'}});
_pr_ad_connection.sendMessageToPub({'addDirectStyles': {'.testclass, #testid1': {'background': '#000'}, '#testid2': {'width': '300px'}}});
//_pr_ad_connection.sendMessageToPub({'overwriteImportantStyles': {'.testclass, #testid1': {'background': '#000'}, '#testid2': {'width': '300px'}}});
}
}