Skip to content

Instantly share code, notes, and snippets.

@stevekarsch
Created August 9, 2017 18:12
Show Gist options
  • Save stevekarsch/e26528ddc7bba04e1cc59889388fa193 to your computer and use it in GitHub Desktop.
Save stevekarsch/e26528ddc7bba04e1cc59889388fa193 to your computer and use it in GitHub Desktop.
OBR.Xg = OBR.Xg || function() {
var c = {},
a = {},
d = !0,
e = OBR;
a.Rh = 1.8;
a.Tb = "ob-readmore-collapse";
a.Z = {
Th: {
ID: 2050,
LIMIT: 1
},
gi: {
ID: 2E3,
LIMIT: 1
}
};
c.j = function(b) {
if (d) {
d = !1;
a.G = b;
var c = a.vd(b);
a.wa = a.Xa(c.Ai);
a.je = a.Xa(c.hm);
a.fe = OBR.F.lc();
a.T = !1;
var h = e.F.ia();
440 < h.width && !a.Ya() || 440 < h.height && a.Ya() ? e.h.log("ReadMore - Screen is wider than 440px") : null === a.wa ? e.h.log("ReadMore - article element doesn't exist") : (h = a.Gi(c, a.wa), a.fd = 0 < a.wa.clientHeight ? a.wa.clientHeight : a.wa.offsetHeight, h >= a.fd ? e.h.log("ReadMore - the setting readMoreButtonYPosition is higher than the selected article.") :
0 > h ? e.h.log("ReadMore - the setting readMoreButtonYPosition is too low for the selected article") : (a.ed = (a.fd - h) / a.Rh, a.Pk(h), a.Kk(c, a.wa), e.Ca.Bc(), e.b.A(window, "scroll", a.Nb), a.D = new e.D(b, "ReadMore"), a.D.setActive(!0 === b.f("readmoreBIEventsEnabled", !0))))
}
};
a.ca = function(b) {
return {
publisherId: b.e("pid", ""),
sectionId: b.e("sid", ""),
widgetJsId: b.e("widgetJsId", ""),
widgetId: b.e("wnid", ""),
uuid: b.e("lsd", ""),
deviceOrientation: a.Ya() ? "landscape" : "portrait",
platform: b.e("readerPlatform", ""),
deviceOs: "",
timestamp: ""
}
};
a.ya = function() {
e.b.K("." + a.Tb + "{max-height:" + a.fd + "px;-webkit-transition:max-height " + a.ed + "ms ease-in;transition:max-height " + a.ed + "ms ease-in;}");
setTimeout(function() {
e.b.K("#ob-readmore-placeholder{visibility:hidden;opacity:0;transition:visibility 1s, opacity 1s linear;}");
setTimeout(function() {
e.b.da(a.wa, a.Tb)
}, 1E3)
}, a.ed);
a.D.o(a.Z.Th, a.ca(a.G), OBR.c.R.aa, {})
};
a.vd = function(a) {
return {
Ie: e.F.ia().height,
im: a.f("readMoreButtonYposition", 1.5),
hm: a.f("readMoreButtonYElementSelector",
""),
Ai: a.f("readMoreArticleElement", ""),
jm: a.f("readMoreText", "Read More")
}
};
a.Xa = function(a) {
var c = null;
0 < a.length && (c = document.querySelector(a));
return c
};
a.Gi = function(b, c) {
var d = OBR.F.wd(c);
return (a.je && e.b.bl(a.wa, a.je) ? OBR.F.wd(a.je) : b.Ie * b.im) - d + 100
};
a.Kk = function(b, c) {
var d = e.b.createElement("div", "ob-readmore-placeholder", null, null);
a.Hb = e.b.createElement("a", "ob-readmore-button", null, null);
a.Hb.innerHTML = b.jm;
a.Hb.onclick = a.ya;
d.appendChild(a.Hb);
c.appendChild(d)
};
a.Pk = function(b) {
e.b.K("." +
a.Tb + " {max-height:" + b + "px;overflow:hidden;position:relative;}#ob-readmore-placeholder {opacity:1;position:absolute;bottom:0;left:0;right:0;text-align:center;background:-moz-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,0.46) 8%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 99%);background:-webkit-linear-gradient(top,rgba(255,255,255,0) 0%,rgba(255,255,255,0.46) 8%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 99%);background:linear-gradient(to bottom,rgba(255,255,255,0) 0%,rgba(255,255,255,0.46) 8%,rgba(255,255,255,1) 40%,rgba(255,255,255,1) 99%);}#ob-readmore-button {background-color:white;color:#61B4D6;text-align:center;padding-top:5px;padding-bottom:5px;margin:50px 5px 15px 5px;border-radius:20px;-webkit-border-radius:20px;border-top-left-radius:20px;border-top-right-radius:20px;border-bottom-left-radius:20px;border-bottom-right-radius:20px;border:1px solid #61B4D6;display:block;width:90%;display:inline-block;}");
e.b.J(a.wa, a.Tb)
};
a.Ya = function() {
var a = e.F.ia();
return a.width > a.height
};
a.Nb = function() {
a.T || (a.Hb && !0 === a.fe.Ua(a.Hb, 100) && (a.D.o(a.Z.gi, a.ca(a.G), OBR.c.R.aa, {}), e.b.za(window, "scroll", a.Nb)), setTimeout(function() {
a.T = !1
}, 100), a.T = !0)
};
c.H = function() {
d = !0
};
c.B = function() {
return a
};
return c
}();
OBR.d.v(OBR.d.g.Oc);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment