Last active
April 25, 2017 20:56
-
-
Save walia/16e285dc4624cbb7d18f9ee79bbdb7f9 to your computer and use it in GitHub Desktop.
Apple news MREC test ads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="mraid.js"></script> | |
| <script type="text/javascript"> | |
| function setupAd() { | |
| var image = document.getElementById('Apple News_Vox_Media_MREC_iPhone'); | |
| var expandedImage = document.getElementById('expanded'); | |
| image.addEventListener('click', function() { | |
| var state = mraid.getState(); | |
| if (state === "default") { | |
| mraid.expand(); | |
| } | |
| }); | |
| expandedImage.addEventListener('click', function(){ | |
| var state = mraid.getState(); | |
| if (state === "expanded") { | |
| mraid.open('https://theverge.com'); | |
| } | |
| }); | |
| mraid.addEventListener("stateChange", toggleOverlay); | |
| } | |
| function toggleOverlay(state) { | |
| if (state == "expanded") { | |
| var image = document.getElementById('expanded'); | |
| var mrec = document.getElementById('Apple News_Vox_Media_MREC_iPhone'); | |
| image.style.display = "inline"; | |
| mrec.style.display = "none"; | |
| var adExpanded = 'https://pubads.g.doubleclick.net/gampad/ad?iu=/172968584/Impression_Trackers/Briar*Nate_Integration_Tests/Apple-News/ImpTracker3&sz=1x1&c=%%CACHEBUSTER%%' | |
| addTracker(adExpanded); | |
| } else if (state == "default") { | |
| var image = document.getElementById('expanded'); | |
| var mrec = document.getElementById('Apple News_Vox_Media_MREC_iPhone'); | |
| image.style.display = "none"; | |
| mrec.style.display = "inline"; | |
| } | |
| } | |
| function addTracker(url) { | |
| var image = document.createElement("img"); | |
| image.setAttribute('src', url); | |
| image.setAttribute('height', '1'); | |
| image.setAttribute('width', '1'); | |
| image.setAttribute('style', 'position:absolute; top:0; left:0; visibility:hidden;'); | |
| var element = document.body; | |
| element.insertBefore(image, element.firstChild); | |
| } | |
| if (mraid.getState() === 'loading') { | |
| mraid.addEventListener('ready', setupAd); | |
| } else { | |
| setupAd(); | |
| var adLoaded = 'https://pubads.g.doubleclick.net/gampad/ad?iu=/172968584/Impression_Trackers/Briar*Nate_Integration_Tests/Apple-News/ImpTracker2&sz=1x1&c=%%CACHEBUSTER%%' | |
| addTracker(adLoaded); | |
| } | |
| </script> | |
| <style type="text/css"> | |
| #expanded { | |
| display: none; | |
| } | |
| </style> | |
| <div> | |
| <img id="expanded" | |
| width="414" height="736" | |
| src="https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8407233/colony-1242-2208_3x.0.jpg" | |
| srcset="https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8407233/colony-1242-2208_3x.0.jpg 3x, | |
| https://cdn1.vox-cdn.com/uploads/chorus_asset/file/8407239/colony-1242-2208_2x.0.jpg 2x, | |
| https://cdn3.vox-cdn.com/uploads/chorus_asset/file/8407241/colony-1242-2208.0.jpg 1x" /> | |
| <img id="Apple News_Vox_Media_MREC_iPhone" | |
| width="300" height="250" | |
| src="https://cdn1.vox-cdn.com/uploads/chorus_asset/file/8405997/colony-900-750_3x.0.png" | |
| srcset="https://cdn1.vox-cdn.com/uploads/chorus_asset/file/8405997/colony-900-750_3x.0.png 3x, | |
| https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8406009/colony-900-750_2x.0.png 2x, | |
| https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8406007/colony-900-750.0.png 1x"/> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="mraid.js"></script> | |
| <script type="text/javascript"> | |
| function setupAd(){ | |
| var image = document.getElementById('Apple News_Vox_Media_MREC_iPhone'); | |
| image.addEventListener('click', function(){ | |
| mraid.open('https://theverge.com'); | |
| }); | |
| } | |
| function addTracker(url){ | |
| var image = document.createElement("img"); | |
| image.setAttribute('src', url); | |
| image.setAttribute('height', '1'); | |
| image.setAttribute('width', '1'); | |
| image.setAttribute('style', 'position:absolute; top:0; left:0; visibility:hidden;'); | |
| var element = document.body; | |
| element.insertBefore(image, element.firstChild); | |
| } | |
| if(mraid.getState() === 'loading') { | |
| mraid.addEventListener('ready', setupAd); | |
| } else { | |
| setupAd(); | |
| var adLoaded = "https://pubads.g.doubleclick.net/gampad/ad?iu=/172968584/Impression_Trackers/Briar*Nate_Integration_Tests/Apple-News/ImpTracker1&sz=1x1&c=%%CACHEBUSTER%%" | |
| addTracker(adLoaded); | |
| } | |
| </script> | |
| <div> | |
| <img id="Apple News_Vox_Media_MREC_iPhone" | |
| width="300" height="250" | |
| src="https://cdn1.vox-cdn.com/uploads/chorus_asset/file/8405997/colony-900-750_3x.0.png" | |
| srcset="https://cdn1.vox-cdn.com/uploads/chorus_asset/file/8405997/colony-900-750_3x.0.png 3x, | |
| https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8406009/colony-900-750_2x.0.png 2x, | |
| https://cdn2.vox-cdn.com/uploads/chorus_asset/file/8406007/colony-900-750.0.png 1x"/> | |
| </div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment