Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save miketaylr/f4161de8c621a65b2692f722c02d8ae5 to your computer and use it in GitHub Desktop.
Save miketaylr/f4161de8c621a65b2692f722c02d8ae5 to your computer and use it in GitHub Desktop.
this.set_box_blur = function(t) {
var i = t.getOffsetParent()
, r = i.select("div.graphic_image_warning")[0]
, a = t.select("video.graphic_image")[0]
, s = null
, o = t.select(".sub_buzz_content__mp4")
, n = "img.graphic_image"
, l = i.select(".click_to_blur")[0]
, u = Prototype.Browser.WebKit && !isSafari5() || isIE9()
, _ = Prototype.Browser.Gecko && !isIE11()
, f = isIE11()
, c = "";
var d = function() {
var t = !a || !s.getAttribute("data-mp4_url") || s.getAttribute("data-mp4_error") !== null ? s : a;
if (a && a.getAttribute("data-status") === "not_loaded") {
t = s.parentElement.nextElementSibling.firstElementChild
}
if (u) {
t.addClassName("graphic_image")
} else if (_) {
t.setAttribute("style", "filter:url(" + c + ");")
} else if (f) {
$$("#" + s.id + " image")[0].style.filter = "url(#blur-effect-" + s.id.replace("svg-image-blur-", "") + ")"
} else {
i.select(".image_block")[0].removeClassName("hidden")
}
r.removeClassName("hidden");
l.addClassName("hidden");
i.removeClassName("no_blur")
}
;
var b = function() {
var t = !a || !s.getAttribute("data-mp4_url") || s.getAttribute("data-mp4_error") !== null ? s : a;
if (a && a.getAttribute("data-status") === "not_loaded") {
t = s.parentElement.nextElementSibling.firstElementChild
}
if (u) {
t.removeClassName("graphic_image")
} else if (_) {
t.setAttribute("style", "")
} else if (f) {
$$("#" + s.id + " image")[0].style.filter = ""
} else {
$s("#" + i.identify() + " .image_block").addClassName("hidden")
}
r.addClassName("hidden");
l.removeClassName("hidden");
i.addClassName("no_blur")
}
;
if (!!a && o.length) {
s = o.first().select(n)[0]
} else {
s = t.select(n)[0]
}
if (f) {
r.style.top = s.getAttribute("height") / 2 * -1 + "px";
s.remove();
s = t.select("svg")[0];
s.style.display = ""
}
if (BF_STATIC.bf_env == "dev" || BF_STATIC.bf_env == "live") {
c = BF_STATIC.image_root + "/static/images/public/quickpost/blur.svg#blur30"
} else if (BF_STATIC.bf_env == "stage") {
c = "http://stage.buzzfeed.com/static/images/public/quickpost/blur.svg#blur30"
}
d();
if (!isIE11())
s.addClassName("box_blur");
t.observe("click", function() {
b()
});
l.observe("click", function() {
d()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment