Skip to content

Commit dc4c2ea

Browse files
committed
Updates to compliance ads, documentation based on MRAID committee feedback
1 parent 7beefd0 commit dc4c2ea

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed
1.3 KB
Binary file not shown.

compliance/units/interstitial.txt

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
<script src="mraid.js" type="text/javascript"></script>
1+
<!-- This IAB MRAID test creative was built by Adam Schuetz, currently Senior Director of Engineering at AdMarvel on 04/14/2014 -->
2+
3+
<script src="mraid.js"></script>
4+
25
<div id="container" style="width:100%;height:100%;background-color:#000000;">
3-
<video id="adVideo" webkit-playsinline src="http://once.unicornmedia.com/now/od/auto/d8371d05-0b04-42fc-892f-b0e9ad6db2b5/6fd31a0f-775a-49ca-849b-228d70b5f9ac/87c56e71-2005-473c-a8da-2d45053413a9/578-1588-iab-video-small.mp4"></video>
6+
<video id="adVideo" webkit-playsinline src="http://once.unicornmedia.com/now/od/auto/d8371d05-0b04-42fc-892f-b0e9ad6db2b5/6fd31a0f-775a-49ca-849b-228d70b5f9ac/87c56e71-2005-473c-a8da-2d45053413a9/578-1588-iab-video-small.mp4"></video>
47
</div>
58

69
<style type="text/css">
@@ -12,7 +15,9 @@ body
1215

1316
<script language="javascript" type="text/javascript">
1417
document.getElementById("container").addEventListener('touchmove', function(event) { event.preventDefault(); }, false);
18+
</script>
1519

20+
<script>
1621
function mraidIsReady()
1722
{
1823
mraid.removeEventListener("ready", mraidIsReady);
@@ -110,43 +115,44 @@ function viewableChangeAfterDisplay(visible)
110115

111116
function showMyAd()
112117
{
113-
// Adjust dimensions for device using current orientation to find landscape values
114-
var screenSize = mraid.getScreenSize();
115-
logMRAIDMessage("Reported screen size: width = " + screenSize.width + ", height = " + screenSize.height);
116-
var screenLandscapeWidth = screenSize.width;
117-
var screenLandscapeHeight = screenSize.height;
118-
document.getElementById("container").style.width = screenLandscapeWidth + "px";
119-
document.getElementById("container").style.height = screenLandscapeHeight + "px";
118+
// Adjust dimensions to current position width/height. Since this is being called on display this should represent the size of the ad after locking to landscape orientation.
119+
var currentPosition = mraid.getCurrentPosition();
120+
var landscapeWidth = currentPosition.width;
121+
var landscapeHeight = currentPosition.height;
122+
logMRAIDMessage("Reported current ad size: width = " + landscapeWidth + ", height = " + landscapeHeight);
123+
124+
document.getElementById("container").style.width = landscapeWidth + "px";
125+
document.getElementById("container").style.height = landscapeHeight + "px";
120126

121127
// First video to fit full width and and then scale height
122128
var videoWidth = 320;
123129
var videoHeight = 180;
124130
var videoRatio = videoWidth/videoHeight;
125131
var newWidth = videoWidth;
126132
var newHeight = videoHeight;
127-
if(videoWidth > screenLandscapeWidth)
133+
if(videoWidth > landscapeWidth)
128134
{
129-
newWidth = screenLandscapeWidth;
135+
newWidth = landscapeWidth;
130136
newHeight = newWidth/videoRatio;
131137
}
132138
else
133139
{
134-
newWidth = Math.max(screenLandscapeWidth, videoWidth);
140+
newWidth = Math.max(landscapeWidth, videoWidth);
135141
newHeight = newWidth/videoRatio;
136142
}
137143

138144
// If scaled height too big then scale back until it fits
139-
if (newHeight > screenLandscapeHeight)
145+
if (newHeight > landscapeHeight)
140146
{
141147
videoRatio = videoHeight/videoWidth;
142148

143-
newHeight = screenLandscapeHeight;
149+
newHeight = landscapeHeight;
144150
newWidth = newHeight/videoRatio;
145151
}
146152

147153
// Calculate margins to center
148-
var topBottomMargins = (screenLandscapeHeight - newHeight)/2.0;
149-
var leftRightMargins = (screenLandscapeWidth - newWidth)/2.0;
154+
var topBottomMargins = (landscapeHeight - newHeight)/2.0;
155+
var leftRightMargins = (landscapeWidth - newWidth)/2.0;
150156

151157
// Update video dimensions
152158
var video = document.getElementById("adVideo");

0 commit comments

Comments
 (0)