-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMRAID_test_2
255 lines (217 loc) · 7 KB
/
MRAID_test_2
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
Skip to content
Why GitHub?
Team
Enterprise
Explore
Marketplace
Pricing
Search
Sign in
Sign up
benmfaul
/
Mraid
110
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Mraid/test.html
Ben Faul Initial commit
Latest commit 3fccc7f on 3 Aug 2015
History
0 contributors
210 lines (176 sloc) 6.44 KB
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>Hello MRAID</title>
</head>
<body>
<script src="mraid.js"></script>
<div id="adContainer" style="width:320px;margin:0px;padding:0px;background-color:#ffffff;">
<div id="normal" style="display:none;width:320px;height:50px;margin:auto;position:relative;top:0px;left:0px;">
<img width="320" height="50" src="http://admarvel.s3.amazonaws.com/demo/mraid/320x50_click_to_expand.png" onclick="javascript:expand();"/>
</div>
<div id="expanded" style="display:none;width:320px;height:250px;margin:auto;position:relative;top:0px;left:0px;">
<img width="320" height="250" style="position:absolute;top:0px;left:0px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/320x250.png" />
<input type="button" id="closeit" value="x" style="position:absolute;top:15px;left:270px;" onclick='collapse();'/>
<img width="37" height="37" style="position:absolute;top:90px;left:56px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Html_37x37.png" onclick="javascript:openSite('http://www.opera.com');" />
<img width="37" height="37" style="position:absolute;top:90px;left:113px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Location_37x37.png" onclick="javascript:openSite('https://maps.google.com/maps?q=1875+S+Grant+St,+San+Mateo,+CA&hl=en&sll=46.238212,6.864936&sspn=0.135592,0.222816&oq=1875+S&hnear=1875+S+Grant+St,+San+Mateo,+California+94402&t=m&z=17&iwloc=A')" />
<img width="37" height="37" style="position:absolute;top:90px;left:170px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Download_37x37.png" onclick="javascript:openSite('https://itunes.apple.com/us/app/opera-mini-web-browser/id363729560?mt=8&ign-mpt=uo%3D4');" />
<img width="37" height="37" style="position:absolute;top:90px;left:227px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Video_37x37.png" onclick="javascript:playVideo('http://admarvel.s3.amazonaws.com/demo/mraid/OMW_SOUND_VIDEO_RENEW.iPhoneSmall.mp4');" />
<img width="37" height="37" style="position:absolute;top:147px;left:56px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/SMS_37x37.png" onclick="javascript:sendSMS('16502122336');" />
<img width="37" height="37" style="position:absolute;top:147px;left:113px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Photo_37x37.png" onclick="javascript:storePicture('http://admarvel.s3.amazonaws.com/demo/mraid/320x50.png')" />
<img width="37" height="37" style="position:absolute;top:147px;left:170px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Calendar_37x37.png" onclick="javascript:createCalendarEvent()" />
<img width="37" height="37" style="position:absolute;top:147px;left:227px;" src="http://admarvel.s3.amazonaws.com/demo/mraid/Call_37x37.png" onclick="javascript:callNumber('16502122336');" />
</div>
</div>
MRAID stands for Mobile Rich media Ad Interface Definition and specifies an API for
managing interactive creative within the mobile in-app environment. MRAID solves an
analogous problem to VPAID, and was launched when the problem of managing
interactive ads in a mobile environment became apparent. MRAID defines a general
approach for HTML ads that display in any kind of container, but in practice applies to
apps developed for mobile. The IAB currently supports two versions of MRAID: version
1.0 was released in 2011 while version 2.0 was released in 2012. Today, most
native mobile apps implement one of these two versions.
<style type="text/css">
body
{
background-color:#FFFFFF;
}
</style>
<script>
// Expanded Click Action Functions
function openSite(url)
{
mraid.open(url);
}
function sendSMS(number)
{
if (!mraid.supports("sms"))
{
alert("MRAID says SMS is not supported on this device.");
}
else
{
mraid.open("sms://" + number);
}
}
function callNumber(number)
{
if (!mraid.supports("tel"))
{
alert("MRAID says calling is not supported on this device.");
}
else
{
mraid.open("tel://" + number);
}
}
function playVideo(url)
{
mraid.playVideo(url);
}
function storePicture(url)
{
if (!mraid.supports("storePicture"))
{
alert("MRAID says storePicture is not supported on this device.");
}
else
{
mraid.storePicture(url);
}
}
function createCalendarEvent()
{
if (!mraid.supports("calendar"))
{
alert("MRAID says calendar is not supported on this device.");
}
else
{
var calendarObject = {description:"Mayan Apocalypse/End of World", location:"everywhere", start:"2013-12-21T00:00-05:00", end:"2013-12-22T00:00-05:00"};
mraid.createCalendarEvent(calendarObject);
}
}
// Core Ad Functions
function toggleLayer( fromLayer, toLayer )
{
var fromElem, toElem, fromElemStyle, toElemStyle;
fromElem = document.getElementById( fromLayer );
fromElem.style.display = 'none';
toElem = document.getElementById( toLayer );
toElem.style.display = '';
}
function updateAd(state)
{
if (state == "expanded")
{
toggleLayer('normal', 'expanded');
}
else if (state == "default")
{
toggleLayer('expanded', 'normal');
}
}
function centerAd(width, height)
{
var sideMargins = 0;
var topBottomMargins = 0;
if (mraid.getState() == "expanded")
{
sideMargins = (width - 320)/2;
topBottomMargins = (height - 250)/2;
document.getElementById("adContainer").style.margin = topBottomMargins + "px " + sideMargins + "px " + topBottomMargins + "px " + sideMargins + "px";
}
document.getElementById("adContainer").style.margin = topBottomMargins + "px " + sideMargins + "px " + topBottomMargins + "px " + sideMargins + "px";
}
function expand(url)
{
toggleLayer('normal','expanded');
mraid.expand(url);
}
function collapse()
{
toggleLayer('expanded','normal');
mraid.close();
}
function setupViewport(width)
{
var element = document.querySelector("meta[name=viewport]");
if (!element)
{
element = document.createElement("meta");
element.name = "viewport";
element.content = "width=" + width + ", user-scalable=no";
document.getElementsByTagName('head')[0].appendChild(element);
}
else
{
element.content = "width=" + width + ", user-scalable=no";
}
}
setupViewport(320);
function mraidIsReady()
{
mraid.removeEventListener("ready", mraidIsReady);
showMyAd();
}
function showMyAd()
{
var el = document.getElementById("normal");
el.style.display = '';
mraid.addEventListener("stateChange", updateAd);
mraid.addEventListener("sizeChange", centerAd);
mraid.useCustomClose(true);
}
function doReadyCheck()
{
if (mraid.getState() == 'loading')
{
mraid.addEventListener("ready", mraidIsReady);
}
showMyAd();
}
doReadyCheck();
</script>
</html>
© 2020 GitHub, Inc.
Terms
Privacy
Security
Status
Help
Contact GitHub
Pricing
API
Training
Blog
About