Created
January 27, 2017 20:01
-
-
Save tshafer/33c2d7c0e42b9f1608e200f8b2d0b056 to your computer and use it in GitHub Desktop.
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
var w = window, | |
sf = w["$sf"], | |
sfAPI = sf && sf.ext, | |
// Set cookie name | |
myPubCookieName = "foo", | |
myPubCookieValue = "washingtonian-dropdown-ad-viewed", | |
fetchingCookie = false; // Flag | |
function register_content() { | |
var e; | |
try { | |
$sf.ext.register(970, 250, status_update_handler); | |
} catch (e) { | |
// SafeFrame API unavailable. Perform fallbacks here | |
sfAPI = null; | |
} | |
} | |
function get_host_cookie() { | |
var e; | |
try { | |
if (sfAPI && sfAPI.supports("read - cookie")) { | |
fetchingCookie = sfAPI.cookie("washingtonian-dropdown-ad-viewed"); | |
} | |
} catch (e) { | |
fetchingCookie = false; | |
} | |
} | |
function status_update_handler(status, data) { | |
if (status === "geom-update") { | |
return; | |
} | |
if (status == "read-cookie") { | |
hasViewedAd = data; | |
//now do whatever here since you have the cookie data | |
} | |
} | |
var allowedExp = $sf.ext.geom().exp; | |
var config = { | |
push: true, | |
t: 0, | |
l: 0, | |
r: 0, | |
b: 0 | |
}; | |
$sf.ext.expand(config); | |
function collapse() { | |
$sf.ext.collapse(); | |
} | |
function expand() { | |
var height = 160; | |
config.b = height; | |
$sf.ext.expand(config); | |
} | |
adjustDivContainerSize(); | |
}); | |
var isOpen = false; | |
document.getElementById("ad-open").addEventListener("click", function() { | |
if (isClicked == false) { | |
expand(); | |
isOpen = true; | |
} else { | |
collapse(); | |
isOpen = false; | |
} | |
}) | |
if (getCookie('washingtonian-dropdown-ad-viewed')) { | |
setTimeout(expand, 1000); | |
setTimeout(collapse, 5000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment