Skip to content

Instantly share code, notes, and snippets.

@tshafer
Created Jan 27, 2017
Embed
What would you like to do?
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